An unexpected response was received from the server.
Unanswered
Burmese posted this in #help-forum
BurmeseOP
Sometimes for some users, they get the error eventhough the request was successful.
This is my proxy.ts looks like:
This is my proxy.ts looks like:
import { cookies } from "next/headers";
import { NextResponse, type NextRequest } from "next/server";
export default async function proxy(request: NextRequest) {
const requestHeaders = new Headers(request.headers);
const cookieStore = await cookies();
const accessToken = cookieStore.get("access_token");
const onboarding = cookieStore.get("onboarding");
const pathname = request.nextUrl.pathname;
if (
!accessToken &&
(pathname === "/signup/connecting-platforms" ||
pathname === "/profile/name")
) {
return NextResponse.redirect(new URL("/signup", request.url));
}
requestHeaders.set("x-pathname", pathname);
return NextResponse.next({
request: {
headers: requestHeaders,
},
});
}
export const config = {
matcher: [
{
source: "/((?!api|_next/static|_next/image|favicon.ico).*)",
missing: [
{ type: "header", key: "next-router-prefetch" },
{ type: "header", key: "next-action" },
{ type: "header", key: "purpose", value: "prefetch" },
],
},
],
};5 Replies
BurmeseOP
Someone sent this to one of the discussion: https://github.com/vercel/next.js/discussions/87651#discussioncomment-15318387
Is updating x-pathname cause any issues with some of the server functions?
@Burmese Is updating x-pathname cause any issues with some of the server functions?
I wiuld assume so, internally theres a lot of checking to make sure server action stays secure
BurmeseOP
Do you recommend to not update the header in proxy.ts? @alfonsüs ardani
@Burmese Do you recommend to not update the header in proxy.ts? <@194128415954173952>
for server actions, definetly