Skip to content

Commit 695e046

Browse files
committedDec 8, 2021
Set base url in .env
1 parent fd24539 commit 695e046

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
 

‎.env.local.example

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
VITE_API_KEY=
2-
VITE_API_SECRET=
1+
VITE_SIMPLICATE_TENANT_BASE_URL=
2+
VITE_SIMPLICATE_API_KEY=
3+
VITE_SIMPLICATE_API_SECRET=

‎src/composables/use-axios.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import axiosPlugin from 'axios';
22

3+
let tenantURL = import.meta.env.VITE_SIMPLICATE_TENANT_BASE_URL;
4+
if (!tenantURL) {
5+
throw new Error('VITE_SIMPLICATE_TENANT_BASE_URL is not defined');
6+
}
7+
if (!tenantURL.endsWith('/')) {
8+
tenantURL += '/';
9+
}
10+
11+
const baseURL = `${tenantURL}/api/v2/`;
12+
313
export const axios = axiosPlugin.create({
4-
baseURL: 'https://demofonkel.simplicate.nl/api/v2/',
14+
baseURL,
515
timeout: 3000,
616
headers: {
7-
'Authentication-Key': import.meta.env.VITE_API_KEY,
8-
'Authentication-Secret': import.meta.env.VITE_API_SECRET,
9-
}
17+
'Authentication-Key': import.meta.env.VITE_SIMPLICATE_API_KEY,
18+
'Authentication-Secret': import.meta.env.VITE_SIMPLICATE_API_SECRET,
19+
},
1020
});

0 commit comments

Comments
 (0)
Please sign in to comment.