Closed indrajit-kanjilal closed 3 years ago
Found the solution, kindly close and ignore. The trick is to set "strictHeader: false" and "ignoreErrors: true" in server options
var server = new Hapi.Server({
address: 'inmbzp5164.in.dst.ibm.com',
port: 7832,
tls: tls,
routes: {
log: { collect: true },
files: { // for the "inert" plugin, serves static ng libs
relativeTo: Path.join(__dirname, 'public')
},
state: {
parse: true,
failAction: 'log'
}
},
state: {
strictHeader: false,
ignoreErrors: true,
}
});
Support plan
Context
How can we help?
I have a OIDC server integration which adds a non-standard cookie in my browser session. Due to this cookie, any request I make from my angular application to HAPI server, shall generate error, I get rid of these errors by adding "failAction: 'log'
in my HAPI server configuration.
My angular application uses the
"hapi-auth-jwt2": "^10.2.0"
plugin for route authentication.Then I create the Nes server
In my angular app , I create the client
This works like a charm in my incognito window, however with a non-incognito window , I keep getting (In chrome dev console):
Nes connect error: {"type":"server","isNes":true,"statusCode":401,"data":{"error":"Unauthorized","message":"Invalid nes authentication cookie"}}
After looking closely , I see that "socket.js" in Nes plugin is executing the following code:
With my invalid cookies, I guess that this manual cookie parse step is failing and generating exception.
My questions are: 1) Is there a way I can make this work ? 2) Is it necessary to parse all cookies when my authentication type is "direct"? can there be a option not to do the manual parsing or provide a "failAction" ?
Thank you