diff --git a/frontend-react/next.config.ts b/frontend-react/next.config.ts index 20ff786..027c6b2 100755 --- a/frontend-react/next.config.ts +++ b/frontend-react/next.config.ts @@ -1,13 +1,23 @@ import type { NextConfig } from "next"; -import createNextIntlPlugin from 'next-intl/plugin'; - +import createNextIntlPlugin from "next-intl/plugin"; + const withNextIntl = createNextIntlPlugin(); const nextConfig: NextConfig = { /* config options here */ sassOptions: { - silenceDeprecations: ['legacy-js-api'], - } + silenceDeprecations: ["legacy-js-api"], + }, + async rewrites() { + return [ + { + source: "/api/:path*", + destination: `${process.env.API_SERVER}/:path*`, // Zielserver aus Umgebungsvariable + }, + ]; + }, + // This is required to support PostHog trailing slash API requests + skipTrailingSlashRedirect: true, }; export default withNextIntl(nextConfig); diff --git a/frontend-react/src/i18n/routing.ts b/frontend-react/src/i18n/routing.ts index 98aaa05..7557166 100755 --- a/frontend-react/src/i18n/routing.ts +++ b/frontend-react/src/i18n/routing.ts @@ -1,20 +1,20 @@ -import {createNavigation} from 'next-intl/navigation'; -import {defineRouting} from 'next-intl/routing'; +import { createNavigation } from "next-intl/navigation"; +import { defineRouting } from "next-intl/routing"; export const routing = defineRouting({ - locales: ['en', 'de'], - defaultLocale: 'en', + locales: ["en", "de"], + defaultLocale: "en", pathnames: { - '/': '/', - '/pathnames': { - en: '/pathnames', - de: '/pfadnamen' - } - } + "/": "/", + "/pathnames": { + en: "/pathnames", + de: "/pfadnamen", + }, + }, }); export type Pathnames = keyof typeof routing.pathnames; export type Locale = (typeof routing.locales)[number]; -export const {Link, getPathname, redirect, usePathname, useRouter} = - createNavigation(routing); \ No newline at end of file +export const { Link, getPathname, redirect, usePathname, useRouter } = + createNavigation(routing); diff --git a/frontend-react/src/middleware.ts b/frontend-react/src/middleware.ts index 5ca72e8..c6601f7 100755 --- a/frontend-react/src/middleware.ts +++ b/frontend-react/src/middleware.ts @@ -1,20 +1,23 @@ -import createMiddleware from 'next-intl/middleware'; -import {routing} from './i18n/routing'; - +import createMiddleware from "next-intl/middleware"; +import { routing } from "./i18n/routing"; + export default createMiddleware(routing); - + export const config = { // Match only internationalized pathnames matcher: [ // Enable a redirect to a matching locale at the root - '/', + "/", // Set a cookie to remember the previous locale for // all requests that have a locale prefix - '/(de|en)/:path*', + "/(de|en)/:path*", // Enable redirects that add missing locales // (e.g. `/pathnames` -> `/en/pathnames`) - '/((?!_next|_vercel|.*\\..*).*)' - ] -}; \ No newline at end of file + //'/((?!_next|_vercel|.*\\..*).*)' + + // Ausschließen von API-Routen + "/((?!api|_next|_vercel|.*\\..*).*)", + ], +};