QuantumBogosort
QuantumBogosort
SSolidJS
Created by QuantumBogosort on 7/17/2024 in #support
Setting Cookies in API Route with `aws-lambda-streaming` nitro preset.
When trying to set a cookie in a SolidStart api route using vinxi/setCookie - nothing is being set. I'm just trying to figure out if this is a me issue or a possible nitro bug with the lambda streaming preset? Code is below - in the callback api route when I try to access the cookie using vinxi/getCookie I get 'undefined'.
import { sendRedirect, setCookie, getCookie } from "vinxi/http";
import { generateState } from "arctic";
import { github } from "@/lib/auth";

import type { APIEvent } from "@solidjs/start/server";

export async function GET(event: APIEvent) {
const state = generateState();
const url = github.createAuthorizationURL(state);
url.addScopes("read:user", "user:email");

setCookie(event.nativeEvent, "github_oauth_state", state, {
path: "/",
secure: true,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});

return sendRedirect(event.nativeEvent, url.toString());
}
import { sendRedirect, setCookie, getCookie } from "vinxi/http";
import { generateState } from "arctic";
import { github } from "@/lib/auth";

import type { APIEvent } from "@solidjs/start/server";

export async function GET(event: APIEvent) {
const state = generateState();
const url = github.createAuthorizationURL(state);
url.addScopes("read:user", "user:email");

setCookie(event.nativeEvent, "github_oauth_state", state, {
path: "/",
secure: true,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});

return sendRedirect(event.nativeEvent, url.toString());
}
2 replies