Build Front/Back and Deploy to Heroku

  1. Add a Procfile to your project’s root directory:
Procfile
npm run build --prefix frontend
mv frontend/build/* public
rails s
# config/routes.rbRails.application.routes.draw do   namespace :api do
<routes>
end
get "*path", to: "fallback#index", constraints: ->(req) { !req.xhr? && req.format.html? }end
# config/routes.rb

Rails.application.routes.draw do
namespace :api do resources :users resources :people, only: [:index, :update, :show] resources :friends, only: [:create, :index, :destroy, :show] resources :budgets, only: [:create, :index] resources :person_budgets, only: [:index] get '/authorize_user', to: "users#show" post '/login', to: "sessions#login" delete '/logout', to: "sessions#logout" end get "*path", to: "fallback#index", constraints: ->(req) { !req.xhr? && req.format.html? }end
# app/controllers/fallback_controller.rb

class FallbackController < ActionController::Base

def index
render file: 'public/index.html'
end

end
  1. Create a new app on Heroku:
heroku create
heroku buildpacks:add heroku/nodejs --index 1
heroku buildpacks:add heroku/ruby --index 2
git push heroku main
git push heroku testbranch:main
git push --force heroku yourbranch:main
heroku open
heroku run rails db:migrate; heroku run rails db:seed
Error: Cannot run more than 1 Free size dynos.
heroku ps
run.1234 (Free): up 2022/02/16 18:00:09 -0600 (~ 8m ago): bas
heroku ps:stop run.1234
heroku run rails db:migrate; heroku run rails db:seed

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Apache web-server Automation with AWS Using Terraform Tool

Orchestrating a MEL system for portfolios and programs: what we’re testing now

Things I Learned Building My Portfolio Site

Debugging Lives…

LOOPING OPERATION — PYTHON

Build your own Operating System #4

BELLA CIAO (CHFHIEST) Solution — Codechef JuneLong Challenge

Boost Your Coding Productivity With This App

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Delcambre

Michael Delcambre

More from Medium

A Rails API for an Image Gallery Based Project with a React Front-End — Part I

Deploying your RoR and React Js App on Heroku

BMates: My full-stack React.js/Rails web application project

Making An External API Call Using Backend In A [React/Rails] App