rsnext/test/integration/custom-routes/next.config.js

219 lines
5.1 KiB
JavaScript
Raw Normal View History

2019-11-09 23:34:53 +01:00
module.exports = {
// target: 'serverless',
2019-11-09 23:34:53 +01:00
experimental: {
async rewrites() {
2019-11-09 23:34:53 +01:00
return [
{
source: '/to-another',
destination: '/another/one',
},
{
source: '/nav',
destination: '/404',
},
{
source: '/hello-world',
destination: '/static/hello.txt',
},
2019-11-09 23:34:53 +01:00
{
source: '/',
destination: '/another',
2019-11-09 23:34:53 +01:00
},
{
source: '/another',
destination: '/multi-rewrites',
2019-11-09 23:34:53 +01:00
},
{
source: '/first',
destination: '/hello',
2019-11-09 23:34:53 +01:00
},
{
source: '/second',
destination: '/hello-again',
2019-11-09 23:34:53 +01:00
},
{
source: '/to-hello',
destination: '/hello',
},
{
source: '/blog/post-1',
destination: '/blog/post-2',
},
2019-11-09 23:34:53 +01:00
{
source: '/test/:path',
destination: '/:path',
2019-11-09 23:34:53 +01:00
},
{
source: '/test-overwrite/:something/:another',
destination: '/params/this-should-be-the-value',
2019-11-09 23:34:53 +01:00
},
{
source: '/params/:something',
destination: '/with-params',
},
{
source: '/query-rewrite/:section/:name',
destination: '/with-params?first=:section&second=:name',
},
{
source: '/hidden/_next/:path*',
destination: '/_next/:path*',
},
{
source: '/proxy-me/:path*',
destination: 'http://localhost:__EXTERNAL_PORT__/:path*',
},
{
source: '/api-hello',
destination: '/api/hello',
},
{
source: '/api-hello-regex/(.*)',
destination: '/api/hello?name=:1',
},
{
source: '/api-hello-param/:name',
destination: '/api/hello?hello=:name',
},
{
source: '/api-dynamic-param/:name',
destination: '/api/dynamic/:name?hello=:name',
},
{
source: '/:path/post-321',
destination: '/with-params',
},
2019-11-09 23:34:53 +01:00
]
},
async redirects() {
2019-11-09 23:34:53 +01:00
return [
{
source: '/redirect/me/to-about/:lang',
destination: '/:lang/about',
permanent: false,
},
{
source: '/docs/router-status/:code',
destination: '/docs/v2/network/status-codes#:code',
statusCode: 301,
},
{
source: '/docs/github',
destination: '/docs/v2/advanced/now-for-github',
statusCode: 301,
},
{
source: '/docs/v2/advanced/:all(.*)',
destination: '/docs/v2/more/:all',
statusCode: 301,
},
2019-11-09 23:34:53 +01:00
{
source: '/hello/:id/another',
destination: '/blog/:id',
permanent: false,
2019-11-09 23:34:53 +01:00
},
{
source: '/redirect1',
destination: '/',
permanent: false,
2019-11-09 23:34:53 +01:00
},
{
source: '/redirect2',
destination: '/',
statusCode: 301,
2019-11-09 23:34:53 +01:00
},
{
source: '/redirect3',
destination: '/another',
statusCode: 302,
2019-11-09 23:34:53 +01:00
},
{
source: '/redirect4',
destination: '/',
permanent: true,
2019-11-09 23:34:53 +01:00
},
{
source: '/redir-chain1',
destination: '/redir-chain2',
statusCode: 301,
2019-11-09 23:34:53 +01:00
},
{
source: '/redir-chain2',
destination: '/redir-chain3',
statusCode: 302,
2019-11-09 23:34:53 +01:00
},
{
source: '/redir-chain3',
destination: '/',
statusCode: 303,
},
{
source: '/to-external',
destination: 'https://google.com',
permanent: false,
},
{
source: '/query-redirect/:section/:name',
destination: '/with-params?first=:section&second=:name',
permanent: false,
},
{
source: '/unnamed/(first|second)/(.*)',
destination: '/:1/:2',
permanent: false,
},
{
source: '/named-like-unnamed/:0',
destination: '/:0',
permanent: false,
},
{
source: '/redirect-override',
destination: '/thank-you-next',
permanent: false,
},
2019-11-09 23:34:53 +01:00
]
},
async headers() {
return [
{
source: '/add-header',
headers: [
{
key: 'x-custom-header',
value: 'hello world',
},
{
key: 'x-another-header',
value: 'hello again',
},
],
},
{
source: '/my-headers/(.*)',
headers: [
{
key: 'x-first-header',
value: 'first',
},
{
key: 'x-second-header',
value: 'second',
},
],
},
{
source: '/:path*',
headers: [
{
key: 'x-something',
value: 'applied-everywhere',
},
],
},
]
},
},
2019-11-09 23:34:53 +01:00
}