-
Notifications
You must be signed in to change notification settings - Fork 59
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
fix: support for embedded cors for route params #278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would mark it as a fix
Under the hood, the route registered was:
/:id*
and find my way does not support path parameter + wildcard like this.
Note that the preflight out of the /:id
prefix, will not work anymore, still I think it is safe as preflight happens on the same context of other routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -72,7 +72,7 @@ function fastifyCors (fastify, opts, next) { | |||
// remove most headers (such as the Authentication header). | |||
// | |||
// This route simply enables fastify to accept preflight requests. | |||
fastify.options('*', { schema: { hide: hideOptionsRoute } }, (req, reply) => { | |||
fastify.options('/*', { schema: { hide: hideOptionsRoute } }, (req, reply) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we register the url into find-my-way, we do:
prefix + url
so, in this case:
path param: "/:id" + "*" = "/:id*"
static prefix: "/foo" + "*" = "/foo*"
while the 2nd seems to work (but it can generate conflicts in any case), the first one does not work because it is a path parameter + a whilcard
Co-authored-by: Manuel Spigolon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the explaination, understood it, checked the code, checked the tests, still a little bit confused but
LGTM
Any plans of cutting a new release soon with this changes @Uzlopak ? |
Done, thanks for the ping |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@fastify/cors](https://github.com/fastify/fastify-cors) | [`8.4.1` -> `8.4.2`](https://renovatebot.com/diffs/npm/@fastify%2fcors/8.4.1/8.4.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@fastify%2fcors/8.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@fastify%2fcors/8.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@fastify%2fcors/8.4.1/8.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@fastify%2fcors/8.4.1/8.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>fastify/fastify-cors (@​fastify/cors)</summary> ### [`v8.4.2`](https://github.com/fastify/fastify-cors/releases/tag/v8.4.2) [Compare Source](https://github.com/fastify/fastify-cors/compare/v8.4.1...v8.4.2) #### What's Changed - build(dependabot): ignore tap major updates by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/276](https://github.com/fastify/fastify-cors/pull/276) - fix: support for embedded cors for route params by [@​mohammedSlimani](https://github.com/mohammedSlimani) in [https://github.com/fastify/fastify-cors/pull/278](https://github.com/fastify/fastify-cors/pull/278) #### New Contributors - [@​mohammedSlimani](https://github.com/mohammedSlimani) made their first contribution in [https://github.com/fastify/fastify-cors/pull/278](https://github.com/fastify/fastify-cors/pull/278) **Full Changelog**: fastify/fastify-cors@v8.4.1...v8.4.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tomacheese/telcheck). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This reverts commit 9acbafe.
This reverts commit 9acbafe.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct
Description of the bug:
When we try to set cors for a route that has route params, it seems that the cors plugin fails at registering the route and any calls to that route will return a 404 instead.