Shivam
Shivam
CDCloudflare Developers
Created by Shivam on 9/20/2023 in #pages-help
Having double slashes in url, `//` does not invoke middleware in the `/functions` – sample code 👇
I am using middleware in /functions to secure some pages. But when the url has double slashes //, wrangler doesn't run the middleware for the url. I have replicated the issue in a minimal repo here – https://github.com/Shivam010/cloudflare-double-slashes-issue There's a middleware in /functions/secure directory to be applied on all routes of /securehttps://github.com/Shivam010/cloudflare-double-slashes-issue/blob/main/functions/secure/_middleware.js And the /out/secure directory contains a file one.html which should be served at /secure/one (but first the middleware needs to be invoked) Now, the Problem... The middleware is properly invoked on /secure/one route but not on the //secure/one, whenever someone uses a double slash before the middleware directory, it doesn't run the middleware and instead directly serve the pages. Links: Hosted on: https://double-slashes-issue.pages.dev /secure/one route https://double-slashes-issue.pages.dev/secure/one //secure/one route https://double-slashes-issue.pages.dev//secure/one Middleware – https://github.com/Shivam010/cloudflare-double-slashes-issue/blob/main/functions/secure/_middleware.js --- Can somebody help me here!
5 replies
CDCloudflare Developers
Created by Shivam on 8/29/2023 in #general-help
I'm facing some issue when using middleware in `/functions`. Can someone help?
I am using middleware in /functions to secure some pages. But when the url has double slashes //, wrangler doesn't run the middleware for the url. I have replicated the issue in a minimal repo here – https://github.com/Shivam010/cloudflare-double-slashes-issue I have also asked help on wrangler-sdk repo https://github.com/cloudflare/workers-sdk/issues/3677 but it feels like they are overburdened with other issues. Can somebody help me here!
2 replies