mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-16 17:23:24 +03:00
feat: add INTERNAL_BACKEND_URL env variable
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { env } from '$env/dynamic/public';
|
||||
import axios from 'axios';
|
||||
|
||||
abstract class APIService {
|
||||
baseURL: string = '/api';
|
||||
api = axios.create({
|
||||
withCredentials: true
|
||||
});
|
||||
@@ -11,11 +9,11 @@ abstract class APIService {
|
||||
constructor(accessToken?: string) {
|
||||
if (accessToken) {
|
||||
this.api.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`;
|
||||
} else {
|
||||
this.api.defaults.baseURL = '/api';
|
||||
}
|
||||
if (!browser) {
|
||||
this.api.defaults.baseURL = (env.PUBLIC_APP_URL ?? 'http://localhost') + '/api';
|
||||
if (browser) {
|
||||
this.api.defaults.baseURL = '/api';
|
||||
} else {
|
||||
this.api.defaults.baseURL = process?.env?.INTERNAL_BACKEND_URL + '/api';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user