#is it possible to set seachParams and keep them through a Nextresponse.next()??

19 messages · Page 1 of 1 (latest)

idle pine
#

Im trying to follow the next js docs and set a viewport search param from middleware, however supabase my Auth provider, sets up middleware to revalidate cookies from the following video https://www.youtube.com/watch?v=v6UvgfSIjQ0
However this causes the searchParams to be removed, how can I get around or fix it??

Authentication is essential for modern app development! In this video, Jon Meyers configures Supabase Auth to use cookies, and implements OAuth using GitHub in an Email Client, written with the Next.js App Router.

https://supabase.com/docs/guides/auth/social-login/auth-github

The Next.js App Router blurs the lines between Client and Server, th...

▶ Play video
glossy lanternBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

sudden swift
idle pine
#

im not sure thats possible, im adding the search params when the user is unauthenticated to redirect them to the login dialog on the homepage which works, however the createClient method creates a new nextresponse.next with just the headers of the request so it can update cookies, i dont think i can redirect with that

sudden swift
#

well... you modify your response here as well. So why not also like the method that I shared?

idle pine
#

thats a new response and authentication and headers dont matter, the createClient method sets the cookies which are important to keep users logged in

sudden swift
idle pine
#

okay ive tried what you suggested however the params are still not appearing in the url ?

#

although i might be misunderstanding ?

sudden swift
idle pine
#

heres the contents of the createclient method, incase it might help, for the most part i think you can ignore the supabase specifics

sudden swift
idle pine
#

like this ?

sudden swift
idle pine
#

the page crashes entirely due to too many redirects ?

#

it does have the params in the url though

sudden swift
#

ah makes sense, because we rediect in middleware everytime... I guess I can't help you, because I don't know enought how supabase works. Sorry

idle pine
#

ah alright bud, no worries thanks for trying though 🙂