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

wip: router changes to allow method-not-allowed #2067

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olizilla
Copy link
Contributor

add tests for

  • GET /login to return 405 Method Not Allowed
  • POST /login to return 401 Unauthorized if auth header not present

initial work on getting router to find path-but-not-method matches

hampered by the GET /:cid route matching GET /login

see #2066

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans [email protected]

add tests for
- GET /login to return 405 Method Not Allowed
- POST /login to return 401 Unauthorized if auth header not present

initial work on getting router to find path-but-not-method matches

hampered by the `GET /:cid` route matching `GET /login`

see #2066

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <[email protected]>
@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: e04cc59
Status: ✅  Deploy successful!
Preview URL: https://18158d07.nft-storage-1at.pages.dev
Branch Preview URL: https://method-not-allowed.nft-storage-1at.pages.dev

View logs

@@ -124,7 +124,9 @@ r.add(
// Upload
r.add('get', '/check/:cid', withMode(nftCheck, RO), [postCors])
r.add('get', '', withAuth(withMode(nftList, RO)), [postCors])
r.add('get', '/:cid', withAuth(withMode(nftGet, RO)), [postCors])
r.add('get', /^\/(?<cid>ba\S+|Qm\S+)/i, withAuth(withMode(nftGet, RO)), [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we added:

r.add('get', '/login', () => new Response({ status: 405, statusText: 'Method Not Allowed' }), [postCors])
r.add('get', '/:cid', withAuth(withMode(nftGet, RO)), [postCors])
  • No regex
  • Allows other multibases to be supported if we want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants