[英]NEXT JS: Redirec to external URL on Click of button (and not on loading a route)
I have been continiously trying to redirect to an external URL with absolute path using NEXTJS in order to perform oAuth verification.我一直在尝试使用 NEXTJS 使用绝对路径重定向到外部 URL 以执行 oAuth 验证。
I tried using我尝试使用
<button><a href='absolute_path'>Redirect to Website</a></button>
onClick = () => window.location.href = 'absolute_path'
onClick = () => window.location.assign('absolute_path')
But all of these always append the result at the end:但所有这些总是 append 最后的结果:
localhost:3000/absolute_path本地主机:3000/absolute_path
I saw:我看见:
async redirects() {
return [
{
source: '/',
destination: 'https://appcenter.intuit.com/connect/oauth2',
permanent: false,
basePath: false,
},
];
},
But this performs immediate redirect on page load, I don't want that instead I want to redirect to external URL based on a button click so that I could inject URL params on the Go.但这会在页面加载时立即执行重定向,我不希望这样我想基于单击按钮重定向到外部 URL 以便我可以在 Z5F075AE3E1F9D0382FBB8C4F666666666666663666636666666663663
One way could be to modify URL parameters on button click and then writing an expression in the above config
so that it matches and redirects, however that seems to be super complicated so I wanted to know if there's any better solution to this?一种方法是在按钮单击时修改 URL 参数,然后在上面的
config
中编写一个表达式,以便匹配和重定向,但这似乎非常复杂,所以我想知道是否有更好的解决方案?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.