-
-
Save austinwoon/4e7291ea3bf114539993a84f7beb13df to your computer and use it in GitHub Desktop.
Use iron session with create-t3-app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const trpc = createTRPCNext({ | |
config({ ctx }) { | |
return { | |
... | |
/** | |
* @link https://trpc.io/docs/links | |
*/ | |
links: [ | |
..., | |
httpLink({ | |
/* | |
* Set custom request headers on every request from tRPC | |
* @link https://trpc.io/docs/ssr | |
*/ | |
headers() { | |
if (ctx?.req) { | |
// To use SSR properly, you need to forward the client's headers to the server | |
// This is so you can pass through things like cookies when we're server-side rendering | |
// If you're using Node 18, omit the "connection" header | |
const { connection: _connection, ...headers } = ctx.req.headers | |
return { | |
...headers, | |
// Optional: inform server that it's an SSR request | |
'x-ssr': '1', | |
} | |
} | |
}, | |
}), | |
], | |
} | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i also use create-t3-app, but there isn't any createTRPCNext initialization from the default create-t3-app setup. where i must put this file?