Skip to content

Commit f1a915d

Browse files
fix: try to fix base url
1 parent f7731be commit f1a915d

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

next.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ const nextConfig = {
7373
],
7474
};
7575
},
76-
env: {},
76+
env: {
77+
NEXT_PUBLIC_BASE_URL:
78+
process.env.NEXT_PUBLIC_BASE_URL ||
79+
(process.env.VERCEL_ENV === 'production'
80+
? 'https://react.dev'
81+
: process.env.VERCEL_URL
82+
? `https://${process.env.VERCEL_URL}`
83+
: 'http://localhost:3000'),
84+
},
7785
webpack: (config, {dev, isServer, ...options}) => {
7886
if (process.env.ANALYZE) {
7987
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');

src/utils/compileMDX.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,7 @@ const DISK_CACHE_BREAKER = 11;
1414
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515

1616
function getBaseUrl(): string {
17-
if (process.env.NEXT_PUBLIC_BASE_URL) {
18-
return process.env.NEXT_PUBLIC_BASE_URL;
19-
}
20-
if (process.env.VERCEL_ENV === 'production') {
21-
return 'https://react.dev';
22-
}
23-
if (process.env.VERCEL_URL) {
24-
return `https://${process.env.VERCEL_URL}`;
25-
}
26-
return 'http://localhost:3000';
17+
return process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
2718
}
2819

2920
export default async function compileMDX(

0 commit comments

Comments
 (0)