简体   繁体   中英

NEXT JS: Redirec to external URL on Click of button (and not on loading a route)

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文简体   中文繁体   中英对照 版本,有任何建议请联系yoyou2525@163.com。

I have been continiously trying to redirect to an external URL with absolute path using NEXTJS in order to perform oAuth verification.

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:

localhost: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.

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?

No answers.You can refer to the related questions on the right.
4 Click a button and open next url

I want to create a little script by buying something, so I don't have to do everything manually This is the buy button; and now I want to open www ...

暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM