Spaces:
Sleeping
Sleeping
test cookie
Browse filesFiles changed (3)
1232345672 unmodified lines7980818283848586878882838485868788899091import { NextRequest, NextResponse } from "next/server";import { cookies } from "next/headers";import MY_TOKEN_KEY from "@/lib/get-cookie-name";// import { cookies } from "next/headers";// import MY_TOKEN_KEY from "@/lib/get-cookie-name";
export async function GET() { const redirect_uri = process.env.REDIRECT_URI;72 unmodified lines ); } const user = await userResponse.json(); const cookieStore = await cookies(); cookieStore.set(MY_TOKEN_KEY(), response.access_token, { maxAge: response.expires_in, httpOnly: false, secure: true, sameSite: "none", }); // const cookieStore = await cookies(); // cookieStore.set(MY_TOKEN_KEY(), response.access_token, { // maxAge: response.expires_in, // httpOnly: false, // secure: true, // sameSite: "lax", // });
return NextResponse.json( {44 unmodified lines4546474849505144 unmodified lines
if (!message.code) return; if (message.type === "user-oauth" && message?.code && !events.code) { console.log("Received code from broadcast channel:", message.code); loginFromCode(message.code); } });53 unmodified lines545556575859601 unmodified line626364646566676869706566676869707172737453 unmodified lines };
const loginFromCode = async (code: string) => { console.log("Login from code => ", code); setLoadingAuth(true); if (loadingAuth) return; await api1 unmodified line .then(async (res: any) => { if (res.data) { // fix to be able to set the cookie through the space (Hugging Face) // setCookie(res.data.access_token, { // expires: res.data.expires_in // ? new Date(Date.now() + res.data.expires_in * 1000) // : undefined, // sameSite: "none", // secure: true, // }); setCookie(res.data.access_token, { expires: res.data.expires_in ? new Date(Date.now() + res.data.expires_in * 1000) : undefined, sameSite: "none", secure: true, }); client.setQueryData(["user.me"], { user: res.data.user, errCode: null,app/api/auth/route.ts+9-9
components/contexts/app-context.tsx+1
hooks/useUser.ts+8-7