added backend reverse proxy to next to directly fetch data from client

This commit is contained in:
Jean Jacques Avril 2025-01-01 10:28:26 +00:00
parent e06753fb24
commit cf3c34fb2f
No known key found for this signature in database
3 changed files with 38 additions and 25 deletions

View File

@ -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);

View File

@ -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);
export const { Link, getPathname, redirect, usePathname, useRouter } =
createNavigation(routing);

View File

@ -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|.*\\..*).*)'
]
};
//'/((?!_next|_vercel|.*\\..*).*)'
// Ausschließen von API-Routen
"/((?!api|_next|_vercel|.*\\..*).*)",
],
};