In Nextjs how do you set serachParams in middleware ?
currently in my middleware im trying to add a user agent viewport serachParam to requests as seen in the nextjs docs here : https://nextjs.org/docs/app/api-reference/functions/userAgent , however supabase my auth provider also has middleware to validate cookies seen here : https://www.youtube.com/watch?v=v6UvgfSIjQ0, is it possible to merge these two and have a response return with my serachParams
Functions: userAgent | Next.js
The userAgent helper extends the Web Request API with additional properties and methods to interact with the user agent object from the request.
Supabase
YouTube
The Right Way to do Auth with the Next.js App Router - UPDATED
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...
12 Replies
bump
just add a new search param
do
url.searchParams.set("dialog", "users")
and
url.searchParams.set('viewport', viewport)
there is no problem in having both searchParams
thats fine, the issue im currently seeing is the params im setting are not appearing in the url if the user is authenticated
even with my solution?
yup, this is my current middlewhere where i set the viewport, the redirect ot the home page and dialog gets added if the user is not authenticated (i see both of those params in the url in that scenario) however, if the user is authenticated and theyre going to say the profile page there is no viewport query in the url
sorry forgot to press reply ^
could you console.log the response from supabase and the request
I have the feeling that supabase does not care about the search params and deletes them
sorry for the long reply, window 10 terminal is being a pain and putting things in objects, heres the output
code
but i have also checked getting the params in a server component and they do get removed
if i add the params manuall like localhost:3000/events?test=abc , the params stay
the first thing the createClient method does it create an unmodified response like so, so i expect that takes out all the params ?
As I dont now these APIs well enough you could console log to check if the response in this example is with or without the search params
Yup same response as above, doesn't have the search params as far as I can tell