At the risk of getting pointed to https://xyproblem.info/ I'll start with what I'm trying to do.
I have an OAuth connection on my site to Spotify. It's a simple connection: /page -> www.spotify.com/auth -> /redirect?next=page -> /page
Right now, I'm passing state to the Spotify auth page and then doing a clientside redirect at /redirect. Technically this works but it creates a flash of text on the redirect page that seems totally unnecessary (not to mention extra request to the server).
My solution is to create a server-side redirect at /redirect that reads the query param called "next" and redirects straight to that. When I create the redirect rule though, Next pops out a "invalid url" error with no info about what URL it's trying to construct. Here's what I have in my next config:
async redirects() {
return [
{
source: '/redirect',
permanent: false,
has: [
{
type: 'query',
key: 'state',
value: '(?<next>.*)',
}
],
destination: `:next`,
},
]
},