Route /auth and /config to local API; everything else uses API_URL
This commit is contained in:
1 parent
1063980b43
commit
0be5b5aa26
2 files changed
+36
-4
No files matched your search
@@ -11,19 +11,19 @@ test('uses basePath with the default api path', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('uses a relative API_URL', () => {
|
||||
test('routes calls through a relative API_URL', () => {
|
||||
expect(getApiUrl('/websites', { apiUrl: '/backend/api', basePath: '' })).toBe(
|
||||
'/backend/api/websites',
|
||||
);
|
||||
});
|
||||
|
||||
test('uses basePath with a relative API_URL', () => {
|
||||
test('routes calls through basePath with a relative API_URL', () => {
|
||||
expect(getApiUrl('/websites', { apiUrl: '/backend/api', basePath: '/analytics' })).toBe(
|
||||
'/analytics/backend/api/websites',
|
||||
);
|
||||
});
|
||||
|
||||
test('uses an absolute API_URL directly', () => {
|
||||
test('routes calls through an absolute API_URL', () => {
|
||||
expect(getApiUrl('/websites', { apiUrl: 'https://api.example.com/api', basePath: '' })).toBe(
|
||||
'https://api.example.com/api/websites',
|
||||
);
|
||||
@@ -34,3 +34,24 @@ test('leaves absolute request URLs unchanged', () => {
|
||||
'https://example.com/custom',
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps /auth/* on the default api path', () => {
|
||||
expect(
|
||||
getApiUrl('/auth/login', { apiUrl: 'https://api.example.com/api', basePath: '' }),
|
||||
).toBe('/api/auth/login');
|
||||
});
|
||||
|
||||
test('keeps /config on the default api path', () => {
|
||||
expect(getApiUrl('/config', { apiUrl: 'https://api.example.com/api', basePath: '' })).toBe(
|
||||
'/api/config',
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps /auth/* on the default api path with basePath', () => {
|
||||
expect(
|
||||
getApiUrl('/auth/verify', {
|
||||
apiUrl: 'https://api.example.com/api',
|
||||
basePath: '/analytics',
|
||||
}),
|
||||
).toBe('/analytics/api/auth/verify');
|
||||
});
|
||||
Reference in new issue
Block a user