-
Notifications
You must be signed in to change notification settings - Fork 155
[BUG] Cookies matcher doesn't work properly (cookies wrongly parsed it seems) #888
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
Comments
Moving the issue to the aws repo where the issue should be fixed. I think we have multiple issues here: Request cookies are in the form So I believe we should not use
We should double check all the usage of |
IIRC, the problem was that the The As Victor said, I think the function is correct, it's probably being used in the wrong place. |
Should we consider using the package cookie for parsing the cookie header on incoming request headers? Next uses it and it has been battle tested for years. The request coming in here is wrong. The opennextjs-aws/packages/tests-unit/tests/converters/node.test.ts Lines 181 to 195 in ab492ca
|
@sommeeeer I have a PR coming (using the pkg), I'll update node.test.ts as you pointed in the message. |
Great @vicb |
Describe the bug
We have a missing cookie rewrite which doesn't work. After some debugging, it seems like the issue is in cookies being wrongly parsed.
Cookies passed to the matcher:
cookies { _ga: 'xxx; codeVariant' }
Cookies from the headers:
cookie: 'xxx; codeVariant=TS; codeStyling=none; _ga_XJ83JQEK7J=xxx; crisp-client%2Fsession%2Fd4cd5bac-6848-4f4d-9a7f-082f5b324b79=xxx; _octo=xxx; sidebar:state=false; cpu_bucket=xxx; preferred_color_mode=xxx; tz=xxx; test=xxx'
This implementation is wrong:
opennextjs-aws/packages/open-next/src/http/util.ts
Line 39 in ab492ca
Cookies are semicolon-separated, not comma-separated.
Steps to reproduce
Add a rewrite to next.config:
async rewrites() { return { beforeFiles: [ { source: "/test", destination: "https://github.com", missing: [ { type: "cookie", key: "test", }, ], }, ], }; },
Add a cookie
test
with any value.The rewrite will always pass.
Expected behavior
Rewrite should
@opennextjs/cloudflare version
1.0.4
Wrangler version
4.17.0
next info output
Additional context
No response
The text was updated successfully, but these errors were encountered: