hapijs/cookie

I get redirected to on an Auth route with 'optional' mode

Zedonboy opened this issue ยท 6 comments

I have a route with mode 'optional', but i made the property redirectTo = '/login' in auth config.

my problem, is when hapi hit that route, it get redirected to login route, hapi suppose to hit the handler, since its mode is "optional" or "try"

tell me what am getting wong.

I was wondering about this, too. It isn't mentioned in the README, but I think right now you have to add the following to your route config:

plugins: { 'hapi-auth-cookie': { redirectTo: false } }

For example:

{
  method : 'GET',
  path : '/optional',
  config : {
    handler : (request,reply) => reply('<h2>optional</h2>'),
    auth: { mode: 'optional' },
    plugins: { 'hapi-auth-cookie': { redirectTo: false } }
  }
},

Basically, the route's auth mode is being ignored when redirectTo is set. There is an open pull request here, as well as discussion here and here that go into a little more detail.

Thanks,

Hello,
I am using hapijs server in kibana plugin.
Problem I am facing is that the redirectTo is not working, I have already provided a handler and path to that handler is '/login'. Every time I am redirecting it to login through redirectTo it is showing error:{"statusCode":404,"error":"Not Found","message":"Not Found"}.
Please help me regarding this.

On another note, please don't hijack the 1st random issue you find, create your own, it's unmanageable otherwise.

lock commented

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.