serve frontend from rails through protected route
This commit is contained in:
2
Procfile
Normal file
2
Procfile
Normal file
@@ -0,0 +1,2 @@
|
||||
web: bundle exec rails s
|
||||
release: bundle exec rails db:migrate
|
||||
@@ -1,7 +1,12 @@
|
||||
class ApplicationController < ActionController::API
|
||||
include Response
|
||||
include ActionView::Layouts
|
||||
|
||||
include ActionController::HttpAuthentication::Basic::ControllerMethods
|
||||
http_basic_authenticate_with name: ENV['BASIC_AUTH_USERNAME'],
|
||||
password: ENV['BASIC_AUTH_PASSWORD']
|
||||
|
||||
def frontend_index_html
|
||||
render file: 'protected_public/index.html'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,12 @@ Rails.application.routes.draw do
|
||||
get 'cash'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
root to: 'application#frontend_index_html'
|
||||
|
||||
get '*path', to: 'application#frontend_index_html', constraints: lambda { |request|
|
||||
!request.xhr? && request.format.html?
|
||||
}
|
||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||
end
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
{
|
||||
"engines": {
|
||||
"node": "10.15.3",
|
||||
"yarn": "1.15.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn --cwd client install && yarn --cwd client build",
|
||||
"deploy": "cp -a client/build/. protected_public/",
|
||||
"heroku-postbuild": "yarn build && yarn deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-router-dom": "^5.0.1"
|
||||
}
|
||||
|
||||
0
protected_public/.gitkeep
Normal file
0
protected_public/.gitkeep
Normal file
Reference in New Issue
Block a user