Search code examples
reactjsaws-cloud9

How do you run a from-scratch React app on Cloud9?


So I'm obviously a beginner with React, this may be rambling and I and may be crucified, but I've been banging my head against a wall for the last week or so trying to build a hello world app from scratch using React on Cloud9. I've read the official docs, and followed this guide (and half a dozen others) contained within to no avail. Using create-react-app does actually work, but I'd like to know what's going on under the hood. I tried simply ejecting the app I made with CRA, but naturally as soon as I ejected it it stopped working.

I've cloned about 5 or 6 react boilerplates off Github, but none of them produce apps I can actually view in Cloud9, even those specifically configured for C9. Almost all use webpack-dev-server, but even when I specifically flag it to use $IP, $PORT, $C9_HOSTNAME etc. like any other app I've deployed and it successfully compiles and tells me it's running, previewing the app or navigating to the URL returns a blank page or "Invalid Host Header." Does anyone know what could be causing this?


Solution

  • To fix the invalid host header issue, add this to your webpack config file:

    devServer: {
      disableHostCheck: true
    }
    

    If you are still using create-react-app, then you should not be having that issue.