QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.64k stars 1.28k forks source link

[🐞] Bun adapter to support getOrigin like express adapter #5777

Open gnemanja opened 7 months ago

gnemanja commented 7 months ago

Which component is affected?

Qwik City (routing)

Describe the bug

I have NGINX setup as reverse proxy for my qwik city Bun server.

When trying to login with Google, i get this error: Error 400: redirect_uri_mismatch.

Error description shows me that callback uri contains http instead of https.

I tried adding all the different headers through NGINX, didn't help.

Tried adding headers through env file. Didn't help.

Tried adding redirectProxyUrl in plugin@auth.ts, but then I get an error: InvalidCheck: State cookie was missing

One guy on discord seemed to solve this issue by using getOrigin function in his entry.express.ts But I am using Bun, not express.

Looking at source code for Node middleware, I tried changing Buns middleware on lines containing: new URL(request.url) to have https. Didn't help.

Thank You in advance!

Reproduction

impossible to reproduce (bun, nginx)

Steps to reproduce

No response

System Info

'@builder.io/qwik-city/middleware/bun'
'@auth/core'
'@builder.io/qwik-auth'
nginx

Additional Information

No response

gioboa commented 7 months ago

I see. I'm trying to figure out how reproduce this problem. This is really tailored on you environment. The best thing in this kind of scenarios is to split the problems in small steps. Is it working with preview mode in your local machine?

gnemanja commented 7 months ago

On my local machine, I am having http:localhost Google auth allows http for localhost, but only https for domains.

@gioboa thank You for the qwik ( ;) ) response!

gioboa commented 7 months ago

On my local machine, I am having http:localhost Google auth allows http for localhost, but only https for domains.

@gioboa thank You for the qwik ( ;) ) response!

ok, we need the https. Can you try to deploy it on a cloud vendor (Vercel, Netlify, Cloudflare, etc. etc. ) ?

gnemanja commented 7 months ago

Go to my website currently live: amfibija.rs/en login page: https://amfibija.rs/en/auth

Try logging with google

gioboa commented 7 months ago

I had this error image

gnemanja commented 7 months ago

As sorry. Deployed is the solution with adding -- redirectProxyUrl: 'https://amfibija.rs/api/auth' (in plugin@auth.ts)

This is an error I got logged on server when you tried logging in:

Screenshot 2024-01-26 at 18 30 05

I removed redirectProxy and deployed again. Check again and you will get something like this:

Screenshot 2024-01-26 at 18 35 52

Thank You a lot for trying to help! I am truly desperate with this one :D

gioboa commented 7 months ago

same Error 400: redirect_uri_mismatch error here.

gnemanja commented 7 months ago

Also, error details:

Screenshot 2024-01-26 at 18 37 45
gioboa commented 7 months ago

details: redirect_uri=http://amfibija.rs/api/auth/callback/google Let's chat on Discord about this problem. It's something wrong in the configuration.

gnemanja commented 7 months ago

https://discord.com/channels/842438759945601056/1200458096322035873

This the link to the issue I made. Best to chat inside so that someone else can see it one day if we solve it

gnemanja commented 7 months ago

@gioboa please reopen the issue. Bun adapter doesn't support setting ORIGIN

gioboa commented 7 months ago

@gnemanja so I think the issue here is support ORIGIN env variable like the node one. Can you change the title pls?