get
endpoint Typescript error with set-cookie
header
#3754
Answered
by
ignatiusmb
mikenikles
asked this question in
Q&A
-
I have the following export const get: RequestHandler = async ({ url }) => {
const code = url.searchParams.get("code");
const accessToken = await getAccessToken(code);
const user = await getUser(accessToken);
// TODO: Persist user in database
const userCookie = await signJwtAndSerializeCookie(user);
return {
status: 302,
headers: {
"set-cookie": [userCookie],
location: "/",
},
};
}; Typescript is not happy and provides the following error:
If I change the code as follows, the Typescript error is no longer present. export const get: RequestHandler = async ({ url }) => {
const code = url.searchParams.get("code");
const accessToken = await getAccessToken(code);
const user = await getUser(accessToken);
// TODO: Persist user in database
const userCookie = await signJwtAndSerializeCookie(user);
return {
status: 302,
headers: {
- "set-cookie": [userCookie],
location: "/",
},
};
}; It's worth noting this is not a shadow endpoint. I'm curious if anyone else sees this and has an idea how to work around it or whether it's a bug. Thanks, Mike |
Beta Was this translation helpful? Give feedback.
Answered by
ignatiusmb
Feb 7, 2022
Replies: 1 comment 1 reply
-
It's not a bug because |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mikenikles
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not a bug because
headers
will only accept astring
type, it won't work withnew Response
as well. You will need to specify or castuserCookie
as astring
.