-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nextjs 13 middleware, next/link #3352
Comments
Hi @c10ckw0rk, transferring this to the hosting repo so that they can better assist you |
We found the exact same issue while debugging our application. We tried recreating a minimal reproducible example. The repository can be found here: https://github.com/FacundoSpira/amplify-nextlink-middleware-error.
import type { InferGetServerSidePropsType } from 'next';
import Link from 'next/link';
type HomeProps = InferGetServerSidePropsType<typeof getServerSideProps>;
const Home = (props: HomeProps) => {
return (
<main>
<div>
<Link href="/">Home</Link>
<Link href="/page1">Page 1</Link>
<Link href="/page2">Page 2</Link>
</div>
<h1>Server Side Props</h1>
<pre>{JSON.stringify(props, null, 2)}</pre>
</main>
);
};
export const getServerSideProps = () => {
return {
props: {
page: 'Home',
},
};
};
export default Home;
import { NextResponse } from 'next/server';
const middleware = () => {
return NextResponse.next();
};
export default middleware;
export const config = {
matcher: ['/((?!static|.*\\..*|_next|favicon.ico).*)', '/'],
}; Expected behaviourWhen navigating through the different links, the page should always render the information received from getServerSideProps. Actual behaviourRandomly when navigating through the links, sometimes getServerSideProps return an empty object. That behaviour can be seen on the following video: Screen.Recording.2023-08-18.at.16.27.08.movSteps to reproduceDeploy the repository to amplify and navigate through the links. The linked repository is also deployed here: https://main.d3g9j0bpx2nsb4.amplifyapp.com/ |
Same issue here |
We are tracking this as a bug here: #3704. I'll recommend subscribing to it for any updates. Closing as duplicate. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
This issue has been automatically locked. |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Not applicable
Amplify Categories
Not applicable
Environment information
Describe the bug
I have a project where I am using nextjs as a headless CMS. The CMS provides a set of urls which map to different templates, any url can have any template so I am using nextjs middleware to perform rewrites on the urls.
I have a demo project deployed here (https://danielpe-middleware-refactor.d327zut72dh116.amplifyapp.com/some-random-pathname-1) (Git repo https://github.com/c10ckw0rk/middleware-getserversideprops-standalone-demo).
When using the
next/link
component after you click around for a while the page will just throw an error. Its intermittent, it seems the faster I click through links, the quicker the page errors. I have also made a component which just does arouter.push
on click of ana
tag, and the page never breaks (Manual Links are using my component, Next links are using the next/link).I'm unable to replicate the problem locally, only occurs once the app is deployed amplify.
Expected behavior
The page should not error when next links are clicked
Reproduction steps
Deploy test repo to amplify hosting
Code Snippet
// Put your code below this line.
https://github.com/c10ckw0rk/middleware-getserversideprops-standalone-demo
Log output
aws-exports.js
Not using any configuration
Manual configuration
Not using any configuration
Additional configuration
Not using any configuration
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
The text was updated successfully, but these errors were encountered: