"trailingSlash" causing CORS errors
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/tippfelher/nextjs-redirect-issue
To Reproduce
Open https://nextjs-permanent-redirect-issue.vercel.app/something
The response header correctly contains Access-Control-Allow-Origin: *
Open https://nextjs-permanent-redirect-issue.vercel.app/something/
The response header contains no Access-Control-Allow-Origin: *
Current vs. Expected behavior
Open https://nextjs-permanent-redirect-issue.vercel.app/something/
The response header also contains Access-Control-Allow-Origin: *
Configuring https://nextjs.org/docs/pages/api-reference/next-config-js/trailingSlash is obviously no solution.
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed), Other (Deployed)
Additional context
Repo for reproduction: https://github.com/tippfelher/nextjs-redirect-issue
- Added route (/src/app/something/route.ts)
- Added headers in nextjs.config.js
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction repository and inspect src/app/something/route.ts and nextjs.config.js, then compare the deployed responses for /something and /something/. The fix is complete when both responses include Access-Control-Allow-Origin: *; verify against the linked deployment URLs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100