Skip to content

Commit

Permalink
Use rewrite in next.config instead of middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
amoore108 committed Nov 12, 2024
1 parent 3bbe8eb commit 368d413
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 0 additions & 8 deletions ws-nextjs-app/middleware.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import cspHeaderResponse from './utilities/cspHeaderResponse';
const LOCALHOST_DOMAINS = ['localhost', '127.0.0.1'];

export function middleware(request: NextRequest) {
const url = request.nextUrl;

// Remove '.lite' from the end of the pathname to allow for the correct page to be rendered
if (url.pathname.endsWith('.lite')) {
url.pathname = url.pathname.replace('.lite', '');
return NextResponse.rewrite(url);
}

const hostname = request.headers.get('host') ?? request.nextUrl.hostname;

// Service worker is registered at the root (e.g. /pidgin) so will work as is on Test/Live
Expand Down
8 changes: 8 additions & 0 deletions ws-nextjs-app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ module.exports = {
},
];
},
async rewrites() {
return [
{
source: '/:path*.lite',
destination: '/:path*',
},
];
},
reactStrictMode: true,
distDir: 'build',
output: 'standalone',
Expand Down

0 comments on commit 368d413

Please sign in to comment.