Browse Source

dev\prod env

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
71266ed556
  1. 1
      client/.env.development
  2. 1
      client/.env.production
  3. 5
      client/src/config.ts
  4. 7
      client/src/services/auth.service.ts

1
client/.env.development

@ -0,0 +1 @@
VUE_APP_API_URL="http://localhost:8000/api/"

1
client/.env.production

@ -0,0 +1 @@
VUE_APP_API_URL="/api/"

5
client/src/config.ts

@ -0,0 +1,5 @@
export const API_URL = process.env.VUE_APP_API_URL
if(API_URL === undefined) {
throw new Error("API_URL is undefined!");
}

7
client/src/services/auth.service.ts

@ -1,14 +1,15 @@
import { User } from "@/types/user";
import { API_URL } from "@/config";
import axios from 'axios';
// TODO: get it from config
const API_URL = '/api/auth/';
const AUTH_API_URL = API_URL + 'auth/';
class AuthService {
login(user: User) {
return axios
.post(API_URL + 'signin', {
.post(AUTH_API_URL + 'signin', {
username: user.username,
password: user.password
})
@ -25,7 +26,7 @@ class AuthService {
}
register(user: User) {
return axios.post(API_URL + 'signup', {
return axios.post(AUTH_API_URL + 'signup', {
username: user.username,
email: user.email,
password: user.password

Loading…
Cancel
Save