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.
#Proxy seems to be ok in DEVELOPMENT but in PRODUCTION isnt working
1 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
can you share your package.json?
{
"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
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
Same issue here.
Solved it, yet?
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.
Weird... I've had some code before that had chance to be invalid, once I removed the potentially null data it started to work.
can you share your matcher config?
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
I know...