#Ludvig-redirect

1 messages ยท Page 1 of 1 (latest)

scenic plaza
#

Hi! Have you tried to console.log the two variables window.location.origin and locale?

last pumice
#

Yes. When I'm on localhost:3000, window.location.origin is localhost:3000

#

My logic is saying that when I deploy it to some hosting service, the window.location.origin will match that deployment url

#

But apparently not

scenic plaza
#

This sound reasonable. If Stripe redirects to the wrong URL, it means the value passed to return_url is wrong, or that you are doing another redirect in your code somewhere else.
So could you:

  • Check that you don't have another line of code responsible for the redirect?
  • And console.log the window.location.origin variable when your website is hosted on a different URL?
last pumice
#

Will do

#

So weird

#

console.log is giving me the expected deployment url

#

but it still returns to localhost:3000

#

It makes no sense

#

I have checked my server call to create paymentintent and I haven't done anything with a return url there

#

OOOOHHH

#

my bad

#

I have indeed put a return url somewhere else

#

My apologies

#

I feel so insanely stupid now, been debugging since yesterday

#

Sorry about this. You can close this thread ๐Ÿ˜‚

scenic plaza
#

Programming is hard! I'm glad you managed to resolve the issue ๐Ÿ™‚

last pumice
#

Actually one last question

#

Is it dangerous to do like this:

return_url: `${window.location.origin}/${locale}`,
#

Like window.location.origin

#

Thinking security wise

#

I have about 0 clues on security

scenic plaza
#

I don't know much about security, but this code is on the frontend, so users could potentially change it, whether you use window.location.origin or a hard coded string, so I don't see an issue here.
But you may want to check if the variable window.location.origin is available in all browsers. And it seems to be: https://caniuse.com/?search=window.location