You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the redirect utility exported from @remix-run/node is being phased out for single fetch, I'd like to create my own redirect function that looks something like this:
// There is no ResponseStub type export that I'm aware of
export type SingleFetchResponse = Parameters<
Parameters<typeof unstable_defineLoader>[0]
>[0]['response']
export function redirect({
response,
path,
status = 302,
}: {
response: SingleFetchResponse
path: string
status?: number
}) {
response.status = status
response.headers.set('Location', path)
return response
}
Just trying to gut check that I'm taking the right approach here and not overcomplicating things. Is this a decent solution?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Since the
redirect
utility exported from@remix-run/node
is being phased out for single fetch, I'd like to create my own redirect function that looks something like this:Just trying to gut check that I'm taking the right approach here and not overcomplicating things. Is this a decent solution?
Thanks for any tips!
Beta Was this translation helpful? Give feedback.
All reactions