DEV Community

Discussion on: Using Create-React-App with Express

Collapse
 
rl4444 profile image
Rory L • Edited

Hey Lou, really love this simple version to add a backend to create react app. It's really cool.

I'm having some trouble deploying this to heroku. Is there a particular package.json change I need to make to get this to work? Everything works in development, but when deployed I get an 'invalid host error' rendering on the page with nothing else

My package.json looks like this. I also ran 'npm run build' before deploying.

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.19.0",
    "express": "^4.17.1",
    "radium": "^0.25.2",
    "react": "^16.8.6",
    "react-animations": "^1.0.0",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1",
    "react-slick": "^0.24.0",
    "spiced-pg": "^1.0.0",
    "styled-components": "^4.3.2"
  },
  "engines": {
    "npm": "6.10.0",
    "node": "v10.16.0"
  },
  "proxy": "http://localhost:8080",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
Collapse
 
loujaybee profile image
Lou (🚀 Open Up The Cloud ☁️) • Edited

Given the popularity of the post, I should probably completely overhaul it. A few things have changed in create-react-app since.

Sounds like this though...

facebook.github.io/create-react-ap...

It's probably an issue with your proxy settings. CRA has changed a few bits with regards to proxies since, it's worth taking a look at their docs.