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

corsRouter can absorb non-cors routes at the same path #376

Open
ianmacartney opened this issue Dec 13, 2024 · 0 comments
Open

corsRouter can absorb non-cors routes at the same path #376

ianmacartney opened this issue Dec 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ianmacartney
Copy link
Collaborator

If you do this:

const http = httpRouter();
const cors = corsRouter(http);

http.route({
  path: "/foo",
  method: "POST",
...
});
cors.route({
  path: "/foo",
  method: "GET",
...
});
export default http;

Then the OPTIONS endpoint will say that both POST and GET are allowed, even though only the latter is. It won't return CORS headers from the POST endpoint, but still may mislead browsers.

It's also funky in that this does work:

const http = httpRouter();
const cors = corsRouter(http);

cors.route({
  path: "/foo",
  method: "GET",
...
});
http.route({
  path: "/foo",
  method: "POST",
...
});
export default http;

We should keep track of the methods for each path, not just slurp up every defined method at a path.

@ianmacartney ianmacartney added the bug Something isn't working label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant