Skip to content

Simple react/json-server app that can be (easily?) deployed to heroku.

Notifications You must be signed in to change notification settings

nss-day-cohort-29/c29-heroku-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c29-heroku-test

Simple react/json-server app that can be (easily?) deployed to heroku.

Things to note:

  1. package.json
    • start script runs production build and starts json-server. Static dist files will be served by json-server.
    • start:dev script concurrently runs "normal" create-react-app dev build and json-server on separate ports.
    • json-server dependency
  2. server.js
    • Adds custom route for database resources by appending /api to the start of all db routes
    • Looks at request url and assumes if it doesn't begin with /api to just return the react app
  3. data.js
    • Database interaction module
    • Uses the following code to determine if the app is in production mode and sets the db url accordingly. In DEV mode the json-serve will be running on a separate port than the react dev server. In PROD mode, the json-server will also be serving the static files
    const baseUrl = process.env.NODE_ENV === 'production'
        ? "/api/"
        : "http://localhost:5002/api/";

About

Simple react/json-server app that can be (easily?) deployed to heroku.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published