Open adrienharnay opened 2 years ago
+1 We're facing the same issue in our intercom app embed (because Intercom sends a post request to the page)
Where are you hosting Next.js? (I know @alisalahio is on Vercel 😄)
Hey! This is hosted on Kubernetes.
@leerob Vercel FTW 🔥
@thepinger solved the intercom embed issue temporarily by creating an api route that accepts the post request and redirects to the embedded page (instead of embedding the status page directly)
export default async function handler(req, res) {
if (req.method === 'POST') {
res.redirect(302, '/')
}
}
This seems related to NextJs changes that added explicit rules to disable POST for static pages ref: https://github.com/vercel/next.js/blob/7d52589bd610c9770f3acafb8384e166f91c4400/packages/next/server/next-server.ts#L851-L865
A similar use case was previously handled in https://github.com/vercel/next.js/pull/8323 and a related test case
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
// TODO: Remove this based on resolution for https://github.com/vercel/next.js/issues/35185
export function middleware(req: NextRequest) {
// Only execute for specific pathnames if running this needs to run for at "/pages" to avoid running for all requests
if (req.method === 'POST' && req.nextUrl.pathname === '/') {
// Redirect to the correct static page using semantic 303
// ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303
return NextResponse.redirect(req.nextUrl.clone(), 303);
}
}
Hi @abhishekdev, I'm not getting middlewares to work with Next 12.2.0, so I can't try your workaround...
Are there any news on this issue?
Hi @balazsorban44. I upgraded to Next.js 14.2.2 but this issue still persists. I think the label is still needed.
Verify canary release
Provide environment information
Error: ENOENT: no such file or directory, realpath '/Users/mypath/frontend/info'
What browser are you using? (if relevant)
98.0.87
How are you deploying your application? (if relevant)
/
Describe the Bug
I am using Next.js as a proxy for a legacy Symfony server. Since 12.1.0, I have
405 POST method not allowed
when trying to proxy POST routes, but in 12.0.7 it works. I found nothing mentioning this change in the changelog.Expected Behavior
No changes between 12.0.7 and 12.1.0
To Reproduce
In next.config.js:
Where SYMFONY_URL points to a server with POST routes that are not implemented by the Next.js server.
Try hitting a POST route.