🐛 Issue with middleware redirect in docker

This commit is contained in:
Meier Lukas
2023-08-24 21:37:39 +02:00
parent 8adb05100b
commit cdd710455f
3 changed files with 10 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { env } from 'process';
import { getUrl } from './tools/server/url';
import { client } from './utils/api';
const skippedUrls = [
@@ -41,7 +42,5 @@ export async function middleware(req: NextRequest) {
return NextResponse.next();
}
url.pathname = '/onboard';
return NextResponse.redirect(url);
return NextResponse.redirect(getUrl(req) + '/onboard');
}

View File

@@ -1,9 +1,9 @@
import { Button, Center, Stack, Text, Title, createStyles } from '@mantine/core';
import { GetServerSidePropsContext } from 'next';
import { useTranslation } from 'next-i18next';
import Head from 'next/head';
import Image from 'next/image';
import Link from 'next/link';
import { useTranslation } from 'next-i18next';
import pageNotFoundImage from '~/images/undraw_page_not_found_re_e9o6.svg';
import { pageNotFoundNamespaces } from '~/tools/server/translation-namespaces';
@@ -24,7 +24,7 @@ export default function Custom404() {
<Title>{t('title')}</Title>
<Text>{t('text')}</Text>
<Button component={Link} variant="light" href="/">
<Button component={Link} variant="light" href="/b">
{t('button')}
</Button>
</Stack>

6
src/tools/server/url.ts Normal file
View File

@@ -0,0 +1,6 @@
import { NextRequest } from 'next/server';
export const getUrl = (req: NextRequest) => {
const protocol = req.nextUrl.protocol;
return protocol + '//' + req.headers.get('host');
};