Closed
Description
Describe the bug
I am using "@netlify/plugin-nextjs": "3.3.0"
and "next": "10.2.2"
with webpack5
. I have a thank you page that is forced to accept a POST
request from Salesforce Pardot using getServerSideProps. They don't send back a typical redirect but rather a POST request. This was working fine until the latest @netlify/plugin-nextjs
. See error at the link below.
To Reproduce
Steps to reproduce the behavior:
- Go to https://60a81fe7f9b70f00079a6771--ts-marketing.netlify.app/teamlink-thank-you-3 <- you will see a JSON blob of the error
{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '../chunks/4343.js'\nRequire stack:\n- /var/task/src/netlify/functions/next_teamlinkthankyou3/next_teamlinkthankyou3.js\n- /var/task/next_teamlinkthankyou3.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","trace":["Runtime.ImportModuleError: Error: Cannot find module '../chunks/4343.js'","Require stack:","- /var/task/src/netlify/functions/next_teamlinkthankyou3/next_teamlinkthankyou3.js","- /var/task/next_teamlinkthankyou3.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"]}
Expected behavior
Returns our thank you page (we redirect it to a GET request so the pages does not render a 404 page)
https://teamsnap.com/teamlink-thank-you-2
Versions
- Next.js:
"next": "10.2.2"
- plugin (if installed at fixed version):
"@netlify/plugin-nextjs": "3.3.0"
Here's a minimal next.js page that we use:
import Layout from '../../components/Layout';
export default function TeamlinkThankYou3() {
return (
<Layout
frontmatter={{
title: 'Thank you!',
robots: 'noindex, nofollow',
metadata: {
description: 'Thanks for submitting a form',
},
}}
>
<section className="pb30" id="thankYou">
<div className="container">
<div className="row">
<section className="col-md-9 mb10">
<h1 className="thin mb10 js-thank-you-heading">Thank You!</h1>
<p className="js-thank-you-content h5 mb30">
Check out what TeamSnap Registration can do for you.
</p>
<div className="youtube-wrapper">
<div
className="youtube--lazy js-thank-you-video"
data-embed="7Z1xUHBCHRM"
>
<div className="play-button"></div>
</div>
</div>
</section>
<aside className="col-md-3 mt20" id="sidebar">
<div className="center-text hidden-xs hodden-sm">
<a href="/blog/general-sports/national-girls-women-in-sports-day-stories">
<img
alt="Sign Up For Free"
className="img-thumbnail img-cta mb15 img-responsive"
src="/images/TS_NationalWomensSportsDay_235x276_A.jpg"
/>
</a>
</div>
</aside>
<div className="clear"></div>
</div>
</div>
</section>
</Layout>
);
}
export async function getServerSideProps(context) {
if (context.req.method === 'POST') {
context.res.setHeader('Location', '/teamlink-thank-you-2');
context.res.statusCode = 302;
context.res.method = 'GET';
context.res.end();
return { props: {} };
}
return {
props: {},
};
}