Skip to content

Commit d819ba8

Browse files
committed
fix #85 create env for prod and test
1 parent 6c970ea commit d819ba8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VITE_TEST_API_URL=https://test-api.eventyay.com/v1
2+
VITE_PROD_API_URL=https://api.eventyay.com/v1

src/stores/api.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { mande, defaults } from 'mande'
22
import { defineStore } from 'pinia'
33

44
export const useApiStore = defineStore('api', () => {
5-
let instance = mande('https://test-api.eventyay.com/v1/')
5+
const apiUrl = import.meta.env.PROD ? import.meta.env.VITE_PROD_API_URL : import.meta.env.VITE_TEST_API_URL
6+
let instance = mande(apiUrl)
67

78
function setToken() {
89
const token = localStorage.getItem('token')
@@ -15,7 +16,7 @@ export const useApiStore = defineStore('api', () => {
1516

1617
function newSession(authenticated) {
1718
// reinit
18-
instance = mande('https://test-api.eventyay.com/v1/')
19+
instance = mande(apiUrl)
1920
if (authenticated) {
2021
setToken()
2122
} else {

0 commit comments

Comments
 (0)