-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix trailing slash redirect applying for data request (#45417)
This ensures we don't apply the trailing slash redirect for `_next/data` requests as it can cause props to fail to resolve on client transition. This also fixes `missing` fields not being applied correctly for `headers` and `redirects` as the field wasn't being passed through. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) Closes: #45398 Fixes: #45393 x-ref: #45340
- Loading branch information
Showing
8 changed files
with
398 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/e2e/middleware-trailing-slash/app/pages/html-links.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<ul> | ||
<li> | ||
<Link | ||
id="with-html" | ||
href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037.html" | ||
> | ||
Does not work | ||
</Link> | ||
</li> | ||
<li> | ||
<Link | ||
id="without-html" | ||
href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037" | ||
> | ||
Works | ||
</Link> | ||
</li> | ||
</ul> | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
test/e2e/middleware-trailing-slash/app/pages/product/[...product-params].tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { GetServerSideProps } from 'next' | ||
import React from 'react' | ||
|
||
export interface ProductPageProps { | ||
test: string | ||
} | ||
|
||
const ProductPage = (params: ProductPageProps) => { | ||
return ( | ||
<> | ||
<h1 id="text">Param found: {params.test}</h1> | ||
</> | ||
) | ||
} | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ params }) => { | ||
const joined = Array.isArray(params['product-params']) | ||
? params['product-params'].join(', ') | ||
: params['product-params'] | ||
return { | ||
props: { | ||
test: joined ? joined : 'Not Found', | ||
}, | ||
} | ||
} | ||
|
||
export default ProductPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.