-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Invalid cookie value #2513
Comments
Looks like a validation error, at least I get similar responses when validation fails. Do you have any kind of request validation in there? |
nope, just this: |
Just tried your code, works perfectly here. Can you post the rest of your app.js? |
I've seen that before and I'm not sure what's exactly happening (although nothing as complex as port forwarding was needed, just a simple server). The server wasn't even using any cookie related thing explicitly (no cookie auth etc.). Can you try in an incognito window? |
@edimoldovan var server = new Hapi.Server(); server.start(function () { But there is no issue on the host machine, but where the port is forwarded. @MathieuLoutre Yes, it works in incognito, do you know witch cookie is the issue? |
@seemsindie no clue. But if you find out, I'm interested! |
@MathieuLoutre i have another project on same domain 'localhost', and that project have two cookies, tr and tr_tkn. Can i somehow turn off cookie parsing, or if i can parse what i just want? |
Hum, I'm not 100% sure as I haven't done it myself, but I'd look here: https://github.com/hapijs/hapi/blob/master/API.md#route.config.state |
@MathieuLoutre Yep, i just added config: {
state: {
parse: false, // parse and store in request.state
failAction: 'ignore' // may also be 'ignore' or 'log'
}
} to the route and it's working. |
Nice! Happy that we found a solution :) |
This happens at least when there's a space in the cookie. When dealing with legacy code and migration, this can be an issue. Should hapi really fail completely here? |
I just got the same error on a freshly installed Hapi with the "hello" example from the homepage. After adding the config to the route by Mathieu it worked. Not a good experience. It still worked after deleting all my cookies for the domain (which was localhost). |
thank u very much. |
Wait, you have to ignore a "failAction" to make cookies work? Is there another way? |
@george-norris-salesforce you can also disable the
I had the same problem with a cookie value from a third party which included spaces. This fixed it. |
I solved like this
|
This just happened to me. It happens due to a malformed cookie. The boom error data contains the name of the cookie which is breaking the request parsing. If you delete it, the problem is fixed |
@svallory In case the cookie is generated in a third-party service which you have no control, I recommend the configuration above. |
For posterity, Microsoft's MSAL authentication libraries use un-escaped spaces in their cookie values. Consequently, |
Fixes issue where unescaped spaces in Microsoft Authentication Library (MSAL) cookie values would prevent authentication See GitHub issue: hapijs/hapi#2513 See related CDP pull request: DEFRA/cdp-portal-frontend#597
I have a blank server running with just , and it's working fine. But when i forward the port trough NAT because i have server listening inside VM and when i try to access the API on the host machine i get this:
{"statusCode":400,"error":"Bad Request","message":"Invalid cookie value"}
Any idea why is this happening, and how to fix it?
The text was updated successfully, but these errors were encountered: