SolidJSS
SolidJSโ€ข7mo agoโ€ข
2 replies
zhengkyl

Get intended URL a "use server" query is called from

I have a query that gets a user's info and redirects if they aren't logged in. I want add a redirectUrl parameter to the login page and return them to their intended url.
Using the referer header works if I visit the URL directly, but for client-side navigation using a <A> or navigate() the referer header is from before the navigation completes.

Currently, I am passing the path as a parameter to the query. Is there a better way to do this? One small downside is since the query is called with different keys, the cached value isn't used. Mainly I'd like to avoid manually passing the current path everywhere I use the query.
Was this page helpful?