fix(web): 生产环境忽略本机 API 地址
This commit is contained in:
@@ -12,6 +12,19 @@ test('API base defaults to same-origin in production and localhost in developmen
|
||||
);
|
||||
});
|
||||
|
||||
test('API base ignores local-only absolute URLs in production', () => {
|
||||
for (const localApiUrl of [
|
||||
'http://localhost:3001/api/v1',
|
||||
'http://127.0.0.1:3001/api/v1',
|
||||
'http://0.0.0.0:3001/api/v1',
|
||||
]) {
|
||||
assert.equal(
|
||||
resolveApiBase({ NODE_ENV: 'production', NEXT_PUBLIC_API_URL: localApiUrl }),
|
||||
'/api/v1',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('API requests use the resolved base path', async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
const apiBase = resolveApiBase();
|
||||
|
||||
Reference in New Issue
Block a user