Open xeoneux opened 4 years ago
Indeed! This is a known issue: https://github.com/jekrb/next-absolute-url/issues/12
The fix is to replace the regex we're using with window.location
as you said.
I just haven't made the update yet. To be honest, I've been mostly hands-off with the module. All the most recent changes have pull requests from the community. I'd happily accept a community contribution to fix this bug!
A work around until this gets updated could be to just do:
let { protocol, host } = absoluteUrl(req)
if (window && window.location.href === stagingServerUrl) {
protocol = `http:`
}
protocol should be a setting from the env file. This condition can be removed from the function and use something like
protocol = process.env.APP_PROTOCOL ?? 'http:'
You may consider nextjs-url package
I don't use https for my staging server and the calls there fail because the protocol is always https if the host isn't localhost. How can we fix this? Should it read the protocol from
window.location
ifwindow
is available?