Adding custom headers to "react-scripts start"
See original GitHub issueThis is really helpful when building apps that are meant to be embedded in and interact with another app. For example, the Invision Trello Power-Up used “npm eject” to be able to add the CORS headers that Trello Power-Ups are required to have.
I’m working on a solution in my own fork of react-scripts to avoid ejecting, as suggested in the Guide, but I wanted to get feedback on whether this is a feature that could be merged upstreamed and what it would need to look like.
Here’s what I’m thinking: add a “headers” key to package.json, which contains an object of custom headers as passed to the Webpack dev server:
"headers": {
"Access-Control-Allow-Origin": "*"
}
Other alternatives include adding a "cors": true
or "cors": "*"
option.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Adding custom headers to "react-scripts start" #10210 - GitHub
I would like to be able to set custom HTTP headers when using npm start, i.e. react-scripts start. Currently our proxy provides CSP...
Read more >How to set headers for a React app created using 'create-react ...
Reference: Create React App adding CORS header ... For react-scripts start update your src/setupProxy.js : module.exports = function (app) ...
Read more >[Solved]-How to set headers for a React app created using ...
Coding example for the question How to set headers for a React app created using 'create-react-app'-Reactjs.
Read more >Advanced Configuration - Create React App
Variable Development Production
BROWSER ✓ Used 🚫 Ignored
BROWSER_ARGS ✓ Used 🚫 Ignored
HOST ✓ Used 🚫 Ignored
Read more >Strict Mode - React
In the above example, strict mode checks will not be run against the Header and Footer components. However, ComponentOne and ComponentTwo , as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there a reason CORS could not just be allowed for every origin in the dev server?
If you just want to be able to use cors during dev, you can simply add a chrome extension for that. There are plenty to choose from.
https://chrome.google.com/webstore/search/cors?_category=extensions