-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Setting cors headers on dev server — for iframe #11752
Comments
Hi, you can try the new experimental custom routes feature on the latest version of Next.js You should be able to set CORS headers by adding the below module.exports = {
experimental: {
async headers() {
return [
{
source: '/(.*)?',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*'
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET,HEAD,PUT,PATCH,POST,DELETE'
},
]
}
]
},
// temporary until https://github.com/zeit/next.js/pull/11755
async rewrites() {
return [
{
source: '/:path*',
destination: '/:path*'
}
]
}
}
} |
Thanks! Exactly what I needed! |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
I have two dev Next dev servers running simultaneously to develop one app that wraps another in an iframe. I need to use window communications, but it fails because the two apps are running on different ports.
Expected behavior
I would like to be able to set cors headers while using the dev server without having to write my own server. A simple cli argument would suffice, since this is only for development purposes.
The text was updated successfully, but these errors were encountered: