-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Which project does this relate to?
Start
Describe the bug
I get serialization errors whenever I chain a middleware to a server function and perform any redirect in that server function handler but the redirect works fine and no serialization error occurs when I remove the middleware.
export const createOrgFn = createServerFn({ method: 'POST' })
.middleware([authMiddleware])
.inputValidator(OrgFormSchema)
.handler(async ({ data }) => {
const api = await client()
const res = await api.post('/orgs/create', data)
if (res.data) {
throw redirect({
to: '/$orgSlug',
params: { orgSlug: res.data.data.organization.slug },
})
}
})Error creating organization
The value [object Response] of type "object" cannot be parsed/serialized. There are few workarounds for this problem: - Transform the value in a way that it can be serialized. - If the reference is present on multiple runtimes (isomorphic), you can use the Reference API to map the references.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Create a server function
- Chain a request middleware to that function
- Throw a redirect in the handler of that server function
Expected behavior
I expect the redirect to work fine and no serialization error.
Screenshots or Videos
No response
Platform
- Router / Start Version: [^1.134.12]
- OS: [Linux]
- Browser: [Chrome ]
- Browser Version: [91.1]
- Bundler: [vite]
- Bundler Version: [7.0.0]
Additional context
jonlambert, andrew-from-toronto, SykSama and m9tdev
Metadata
Metadata
Assignees
Labels
No labels