Rank 1: Thread
I using Remix and Appwrite. I currently have a working Login Page that creates the SSR session, but when I try to forward the user agent to get more specific information on the Appwrite console (currently displays Windows 95), it fails. Since the problem is most likely due to my stupidity, I wonder how to forward the agent correctly? Any help is appreciated :)
My Code:
//signin.tsxexport async function action({ request }: ActionFunctionArgs) { let formData = await request.formData(); let email = formData.get("email")?.toString(); let password = formData.get("password")?.toString(); if (!email || !password) { return new Response("Bad Request", { status: 400 }); } let userAgent = request.headers.get("User-Agent")?.toString() ||""; let user = await createSession(email, password, userAgent); if (user) { return redirect("/", { headers: { "Set-Cookie": await authCookie.serialize(user?.secret), }, }); }}
//createSession.ts export async function createSession( email: string, password: string, userAgent: string) { const account = new Account(AdminClient); try { console.log("Creating Session"); const session = await account.createEmailPasswordSession(email, password); console.log(userAgent); AdminClient.setForwardedUserAgent(userAgent); console.log(AdminClient.config); return session; } catch (error) { console.error(error); throw new Error("SignIn failed"); }}