rsnext/examples/middleware-matcher/pages/index.tsx
Max Proske 6290689281
Convert middleware-matcher example to TypeScript (#42520)
Converted example to TypeScript to match Contribution docs.
- Set cookies using `NextResponse` instead of the `Set-Cookie` header

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm build && pnpm lint`
- [X] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-06 06:08:06 +00:00

28 lines
822 B
TypeScript

export default function Home() {
const matching = ['/about', '/about/topic/cats', '/public/disclaimer']
const notMatching = ['/public', '/public/disclaimer/nested', '/static']
return (
<div>
<h1>Middleware matching</h1>
<p>The current middleware configuration is:</p>
<pre>
export const config = {'{'}
<br />
{' '}matcher: [ <br />
{' '}'/public/disclaimer', // match a single, specific page
<br />
{' '}'/((?!public|static).*) // match all pages not starting with
'public' or 'static' <br />
{' '}] <br />
{'}'}
</pre>
<ul>
{[...notMatching, ...matching].map((href) => (
<li key={href}>
<a href={href}>{href}</a>
</li>
))}
</ul>
</div>
)
}