123
This commit is contained in:
@ -3,9 +3,12 @@ const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
eslint: { ignoreDuringBuilds: true },
|
||||
transpilePackages: ['@coursecraft/shared'],
|
||||
// Проксируем /api на бэкенд — в браузере запросы идут на тот же хост, без localhost
|
||||
// Проксируем /api на бэкенд — в браузере запросы идут на тот же хост
|
||||
// INTERNAL_API_URL используется в Docker (не конфликтует с .env),
|
||||
// API_URL — fallback для локальной разработки
|
||||
async rewrites() {
|
||||
const apiUrl = process.env.API_URL || 'http://127.0.0.1:3125';
|
||||
const apiUrl = process.env.INTERNAL_API_URL || process.env.API_URL || 'http://127.0.0.1:3125';
|
||||
console.log('[next.config] rewrites destination:', apiUrl);
|
||||
return [{ source: '/api/:path*', destination: `${apiUrl}/api/:path*` }];
|
||||
},
|
||||
images: {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// В браузере — относительный URL (запросы на тот же хост, Next проксирует /api на бэкенд)
|
||||
const API_BASE =
|
||||
typeof window !== 'undefined' ? '' : (process.env.API_URL || 'http://localhost:3125');
|
||||
typeof window !== 'undefined' ? '' : (process.env.INTERNAL_API_URL || process.env.API_URL || 'http://localhost:3125');
|
||||
const API_URL = API_BASE ? `${API_BASE.replace(/\/$/, '')}/api` : '/api';
|
||||
|
||||
const STORAGE_KEY = 'coursecraft_api_token';
|
||||
|
||||
Reference in New Issue
Block a user