Proxy seems to be ok in DEVELOPMENT but in PRODUCTION isnt working
Unanswered
American black bear posted this in #help-forum
American black bearOP
On my app, if i start it on my pc on localhost everything works just fine. I must say that i have an backend in fastapi that helds all the logic and works thru api with my frontend.
But on my VPS if i run the app in production mode, the proxy seems not to work. I can access pages that normally requires authentication. Is there a problem with the proxy? Beacuse im 6 hours into debugging and thats the conclusion ive reached.
But on my VPS if i run the app in production mode, the proxy seems not to work. I can access pages that normally requires authentication. Is there a problem with the proxy? Beacuse im 6 hours into debugging and thats the conclusion ive reached.
16 Replies
American black bearOP
{
"name": "typescript_bloxit",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"@supabase/supabase-js": "^2.83.0",
"@svgr/webpack": "^8.1.0",
"motion": "^12.23.24",
"next": "^16.1.1",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"sonner": "^2.0.7",
"zustand": "^5.0.8"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"babel-plugin-react-compiler": "1.0.0",
"baseline-browser-mapping": "^2.8.32",
"eslint": "^9",
"eslint-config-next": "16.0.1",
"tailwindcss": "^4",
"typescript": "^5"
}
}
"name": "typescript_bloxit",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"@supabase/supabase-js": "^2.83.0",
"@svgr/webpack": "^8.1.0",
"motion": "^12.23.24",
"next": "^16.1.1",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"sonner": "^2.0.7",
"zustand": "^5.0.8"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"babel-plugin-react-compiler": "1.0.0",
"baseline-browser-mapping": "^2.8.32",
"eslint": "^9",
"eslint-config-next": "16.0.1",
"tailwindcss": "^4",
"typescript": "^5"
}
}
@American black bear {
"name": "typescript_bloxit",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"@supabase/supabase-js": "^2.83.0",
"@svgr/webpack": "^8.1.0",
"motion": "^12.23.24",
"next": "^16.1.1",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"sonner": "^2.0.7",
"zustand": "^5.0.8"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"babel-plugin-react-compiler": "1.0.0",
"baseline-browser-mapping": "^2.8.32",
"eslint": "^9",
"eslint-config-next": "16.0.1",
"tailwindcss": "^4",
"typescript": "^5"
}
}
can you share a screenshot of your folder structure (you can collapse the /app folder) and also a screenshot of your proxy
American black bearOP
proxy is setted good
as i told, on localhost there is no problem
but when i run the app on a VPS it seems that it doesnt work
@B33fb0n3 can you share *a screenshot* of your folder structure (you can collapse the /app folder) and also a screenshot of your proxy
Abyssinian
My proxy is quite simple, and it works as it should on
next dev.//! FIXME (27/12/2025): doesn't run in prod. environment.
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { sendPageViewServer } from "@/lib/analytics";
export async function proxy(request: NextRequest) {
if (
// Exclude API routes
!request.nextUrl.pathname.startsWith("/api") &&
// Exclude Next.js internal assets (JS, CSS, etc)
!request.nextUrl.pathname.startsWith("/_next") &&
// Exclude dashboard/admin routes
!request.nextUrl.pathname.startsWith("/dashboard") &&
// Exclude static files with extensions (images, fonts, etc)
!request.nextUrl.pathname.includes(".")
) {
// Send pageview data to analytics backend
sendPageViewServer({
path: request.nextUrl.pathname,
userAgent: request.headers.get("user-agent"),
}).catch(() => {
// Pass
});
}
return NextResponse.next();
}On dev it works.
@Abyssinian My proxy is quite simple, and it works as it should on `next dev`.
ts
//! FIXME (27/12/2025): doesn't run in prod. environment.
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { sendPageViewServer } from "@/lib/analytics";
export async function proxy(request: NextRequest) {
if (
// Exclude API routes
!request.nextUrl.pathname.startsWith("/api") &&
// Exclude Next.js internal assets (JS, CSS, etc)
!request.nextUrl.pathname.startsWith("/_next") &&
// Exclude dashboard/admin routes
!request.nextUrl.pathname.startsWith("/dashboard") &&
// Exclude static files with extensions (images, fonts, etc)
!request.nextUrl.pathname.includes(".")
) {
// Send pageview data to analytics backend
sendPageViewServer({
path: request.nextUrl.pathname,
userAgent: request.headers.get("user-agent"),
}).catch(() => {
// Pass
});
}
return NextResponse.next();
}
Abyssinian
Weird... I've had some code before that had chance to be invalid, once I removed the potentially null data it started to work.
@B33fb0n3 can you share your `matcher` config?
Abyssinian
Heya, as I mentioned above, it seems if you have some data that may be invalidated it won't work in production environment. Not sure if that's really the case? But I removed about 20% and now it started to work.
@Abyssinian Heya, as I mentioned above, it seems if you have some data that may be invalidated it won't work in production environment. Not sure if that's really the case? But I removed about 20% and now it started to work.
that wouldnt make any sense. Especially that you have no data fetching in your proxy
Abyssinian
I know...
But I haven't changed anything else.