Search code examples
node.jsreactjsexpresscreate-react-app

create-react-app Server + Node Server Without XSS Problems?


I'm using a create-react-app-generated server for my front-end (under the hood it uses Webpack's dev server), and I'm using Node/Express for back-end. Whenever I have this combination, I always run into XSS issues (eg. between localhost:3000 and localhost:4000) because the two servers have to run on different ports.

Given that my production site will be serving everything from the same domain, I don't really need CORS or anything fancy. Is there any sort of easy/hack way to avoid cross-domain issues in such a local dev environment?


Solution

  • You can set the response header "Access-Control-Allow-Origin" to "*" in the express server. This post might help.