How to redirect users outside the domain of the app ?
Unanswered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
I'm looking for a way to redirect my users to an external success or failure page based on the status of some operations. But no matter the method I use, every redirect is made under the same domain.
For example, I'm trying to redirect my users to success.com but they are redirect to https://app-domain/success.com. I used router.push, router.replace, I even used window.location.href and window.location.assign and I get the same result.
The format of the redirect url can vary so, but it is always a valid url (https://success.com, success.com, www.success.com) and I just want a simple to redirect to that URL (not under the domain of the nextjs app)
For example, I'm trying to redirect my users to success.com but they are redirect to https://app-domain/success.com. I used router.push, router.replace, I even used window.location.href and window.location.assign and I get the same result.
The format of the redirect url can vary so, but it is always a valid url (https://success.com, success.com, www.success.com) and I just want a simple to redirect to that URL (not under the domain of the nextjs app)
8 Replies
router.push(“https://url”) works for me. Also your nextjs version
Northeast Congo LionOP
yes sure. the problem is, with the http(s):// form it wors but I want it to work for pretty much every form and I don't know why it doesn't even when I use window.location
Northeast Congo LionOP
My code is nothing fancy, it's just this
That's all but It works only for https:// form of urls and I want to know if it's a normal behavior. To me, I can just write window.location.href = url.com and get redirect to url.com
window.location.href = redirectUrl
That's all but It works only for https:// form of urls and I want to know if it's a normal behavior. To me, I can just write window.location.href = url.com and get redirect to url.com
@Northeast Congo Lion My code is nothing fancy, it's just this window.location.href = redirectUrl
That's all but It works only for https:// form of urls and I want to know if it's a normal behavior. To me, I can just write window.location.href = url.com and get redirect to url.com
Yes it is normal behaviour.
https needs to be there, I’m unsure about http
https needs to be there, I’m unsure about http
Northeast Congo LionOP
Hmmm so my url should always be formatted that way if I want it to work ?
Northeast Congo LionOP
Okay thanks I get it now