Next.js Discord

Discord Forum

How safe import * as context from "next/headers"; is without serverless ?

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
I see this example on lucia auth
// app/signup/page.tsx
import { auth } from "@/auth/lucia";
import * as context from "next/headers";
import { redirect } from "next/navigation";

import Form from "@/components/form";

const Page = async () => {
    const authRequest = auth.handleRequest("GET", context);
    const session = await authRequest.validate();
    if (session) redirect("/");
    // ...
};

export default Page;
 


My concern is about this
 import * as context from "next/headers"; 


I know this is not a problem if you deploy your nextjs app on a serverless infrastructure

But! How would this be safe if you deployed your Nextjs app in a full server ( one long-running process ) like on ec2, render, GCD, etc… so your app would be running with
 next start 


How header context is kept safe? If multiple requests are handled and each has async operations one may resolve before the other
 import * as context from "next/headers"; 


This seems unclear to me

0 Replies