authorizerdev / examples

List of examples on how to use authorizer with various technologies out there.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

authorizerdev with nextJS not working on 12.1.0 & vanillaJS

LuD1161 opened this issue Β· comments

Hey @lakhansamani πŸ‘‹

Awesome work with this. I've been checking your youtube tutorial for integrating this in nextJS but that seems to be not working as expected ( perhaps some SDK changes, not sure ).

Here's the timestamp of the video : https://youtu.be/2GMxfI6WUb8?list=PLSQGbUjHc6bpaAgCiQPzNxiUPr7SkDAFR&t=675
The login button changes to logout.

Though when I am trying, by cloning this repo and running the nextJS example, the access_token remains in the URL bar as a query parameter
image

LMK, what next steps to follow.

Thanks. Regards.
A

Just checked the unpkg hosted library is returning 520 .
image

Hey @LuD1161 ,Thank you for the input. Will let you know about the solution.

Hey, @LuD1161 I have tried but it is working for me with the same example.

@LuD1161 I have verified it,
It is happening because from screenshot I can see that you are using brave browser which does not allow cross domain cookies, so from local host it will not allow setting cookie for demo.authorizer.dev for this you will need to use same domain.

For testing purpose consider using chrome there it works. Else you can set insecure cookies from dashboard till development and that should fix the problem.

Also, this is happening because we have callback redirect from social media login.

I am figuring out a way to fix this for social media on sdk level.

For more info,

if you login into https://authorizer.dev it uses the same instance as of example, i.e.e demo.authorizer.dev and as you can see there it works seamlessly which is again nextjs app.

https://github.com/authorizerdev/authorizer.dev/blob/v3/components/Hero.tsx#L132

Hey @lakhansamani @aggmoulik πŸ‘‹

Thank you for looking into it πŸ™Œ

  1. I tried on firefox as well πŸ€”

image

With my config :
image

  1. I also have disabled the secure cookie option :

image

  1. Tried on chrome as well πŸ€”

image

Still no luck.

I see some error with graphql
image

@LuD1161 policy is same for firefox and brave. It works for me on chrome

Screenshot 2022-10-29 at 5 52 26 PM

Even for chrome it shows unauthorised πŸ€”
image

check the console error too

Can you share package.json info, on which version of SDKs you are using.

Thanks

I've changed next version to ^12.1.0, else on latest ( since recent next release ) it's failing.
image

		"@authorizerdev/authorizer-js": "1.1.0",
		"@authorizerdev/authorizer-react": "1.1.0",

Interesting I tried with same version.
Can you try updating authorizer-react to 1.1.2 once.

Thanks

Other option is you can try deploying your site on heroku and try.

It's the same for authorizer 1.1.2 πŸ˜…
image

I tried logging the token as well πŸ€”
It shows null
image

Okay let me try to debug more and reproduce it,
thanks for patience

Sure. LMK if you wanna hop on a all to debug this πŸ™Œ

I am able to reproduce the issue with your instance. Checking out the heroku cookie strategy.
Seems heroku specific.

@LuD1161 can you once enable secure cookies on your instance from dashboard
Screenshot 2022-10-29 at 6 31 23 PM

@lakhansamani done πŸ–οΈ

Seems to be working , after a weird redirection though πŸ˜„
image

What was the issue πŸ€”
Also how did you fix it on my instance πŸ€”

@LuD1161 seems secure cookie + chrome combination was the issue ;-)
I did not do anything.

Once you configure right domain for app + authorizer instance it will work across all the browser.

I would do something like

xyz.com -> main app (nextjs)
auth.xyz.com -> authorizer instance.

oh okay. so as of now, this works, right ?
secure cookies - πŸ”΄ ( for brave and firefox )
and
secure cookies - 🟒 ( for chrome )

Yes for local development,
But if you configure right domains,
secure cookies - 🟒 (for brave & firefox)

Thanks a lot πŸ™Œ πŸ˜„