Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding custom headers to "react-scripts start" #4861

Closed
ariofrio opened this issue Aug 8, 2018 · 6 comments
Closed

Adding custom headers to "react-scripts start" #4861

ariofrio opened this issue Aug 8, 2018 · 6 comments
Labels

Comments

@ariofrio
Copy link

ariofrio commented Aug 8, 2018

This 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.

@sprlwrksAprilmintacpineda
Copy link

sprlwrksAprilmintacpineda commented Aug 13, 2018

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

@Pajn
Copy link
Contributor

Pajn commented Aug 21, 2018

Is there a reason CORS could not just be allowed for every origin in the dev server?

@stale
Copy link

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018
@lafeber
Copy link

lafeber commented Nov 2, 2018

The cors extensions don't work for us locally, probably due to the same domain but different ports?

@stale stale bot removed the stale label Nov 2, 2018
@stale
Copy link

stale bot commented Dec 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 2, 2018
@stale
Copy link

stale bot commented Dec 8, 2018

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Dec 8, 2018
@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants