Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
66 lines (60 loc) · 1.85 KB
/
Copy pathnext.config.js
File metadata and controls
66 lines (60 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { withPayload } from '@payloadcms/next/withPayload'
import redirects from './redirects.js'
const NEXT_PUBLIC_SERVER_URL = process.env.VERCEL_PROJECT_PRODUCTION_URL
? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`
: undefined || process.env.__NEXT_PRIVATE_ORIGIN || 'http://localhost:3000'
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
...[NEXT_PUBLIC_SERVER_URL /* 'https://example.com' */].map((item) => {
const url = new URL(item)
return {
hostname: url.hostname,
protocol: url.protocol.replace(':', ''),
}
}),
// Allow all .local domains for multi-tenant development
{
protocol: 'http',
hostname: '*.local',
},
// Allow localhost for development
{
protocol: 'http',
hostname: 'localhost',
},
],
},
webpack: (webpackConfig) => {
webpackConfig.resolve.extensionAlias = {
'.cjs': ['.cts', '.cjs'],
'.js': ['.ts', '.tsx', '.js', '.jsx'],
'.mjs': ['.mts', '.mjs'],
}
return webpackConfig
},
reactStrictMode: true,
redirects,
async rewrites() {
return {
beforeFiles: [
{
// Rewrite domain-based requests to path-based routes
// Only applies when NOT accessing via localhost (for true multi-tenant domain routing)
// Excludes admin, api, next, and static assets
// e.g., luxe-hotels.local/about -> /luxe-hotels.local/about
source: '/:path((?!admin|api|next|_next/static|_next/image|favicon.ico).*)*',
destination: '/:tenant/:path*',
has: [
{
type: 'host',
value: '(?<tenant>(?!localhost).*)',
},
],
},
],
}
},
}
export default withPayload(nextConfig, { devBundleServerPackages: false })