-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single fetch response
parameter for loader is undefined if no default export exists in the route
#9314
Comments
Resource routes don't need a The response stub concept for single fetch is needed because those loaders don't return a |
I think this is a breaking change with the new Before, your resource routes could return a naked object and Remix would automatically convert that to a JSON response. Now, if you return a naked object from a resource route, you will get that error message. It's not technically a Remix error. You should check to see if |
yeah, we should probably add a section to the docs to make this more clear, but this section in the docs applies to all loaders/actions - including resource routes.
Resource routes in particular don't do anything special for single fetch - and since there's no longer an automatic conversion we don't have a |
We decided we are going to keep this behavior in v2 for backwards compatibility and to make adoption easier. We'll detect naked objects from resource routes only and convert them to |
Please see the dev branch docs for details on resource routes in single fetch with this change. These changes will be available in the next release. Keeping this issue open as we are going to get the |
I hope we can keep export function getSupabaseServerClient(
request: Request,
response: ResponseStub,
) {
const cookies = parse(request.headers.get("Cookie") ?? "");
return createServerClient(env.SUPABASE_URL, env.SUPABASE_ANON_KEY, {
cookieOptions,
cookies: {
get(key) {
return cookies[key];
},
set(key, value, options) {
response.headers.append("Set-Cookie", serialize(key, value, options));
},
remove(key, options) {
response.headers.append("Set-Cookie", serialize(key, "", options));
},
},
});
} For this specific example, it could be solve with middleware, though. |
This should be resolved by the introduction of |
|
Reproduction
https://stackblitz.com/edit/remix-run-remix-x55her?file=app%2Froutes%2Fno-default.tsx
System Info
Used Package Manager
npm
Expected Behavior
The
response
parameter should always be aResponseStub
, even in resource routes without a default export.Actual Behavior
Visiting a resource route (in the stackblitz:
app/routes/no-default.tsx
) results in the response starting asundefined
and an error being printed to the console:The text was updated successfully, but these errors were encountered: