Use env variable for backend location

This commit is contained in:
sperwing 2024-11-17 15:26:25 +01:00
parent d91702b213
commit 60461d329c
2 changed files with 8 additions and 3 deletions

1
front/bahnui-front/.env Normal file
View File

@ -0,0 +1 @@
VUE_APP_BASE_URL=http://127.0.0.1:3000

View File

@ -23,6 +23,10 @@
<script> <script>
import axios from 'axios'; import axios from 'axios';
const client = axios.create({
baseURL: process.env.VUE_APP_BASE_URL
});
const timecolors = [ const timecolors = [
{r:147, g:147, b:147, h:0}, {r:147, g:147, b:147, h:0},
{r:156, g:151, b:146, h:1}, {r:156, g:151, b:146, h:1},
@ -62,14 +66,14 @@
}, },
methods: { methods: {
searchStationFrom() { searchStationFrom() {
axios.get("http://localhost:3000/searchStation", {params: {text: this.from.name}}).then(res => this.from = {name: res.data.name, id: res.data.id}); client.get("/searchStation", {params: {text: this.from.name}}).then(res => this.from = {name: res.data.name, id: res.data.id});
}, },
searchStationTo() { searchStationTo() {
axios.get("http://localhost:3000/searchStation", {params: {text: this.to.name}}).then(res => this.to = {name: res.data.name, id: res.data.id}); axios.get("/searchStation", {params: {text: this.to.name}}).then(res => this.to = {name: res.data.name, id: res.data.id});
}, },
searchConnection() { searchConnection() {
if (this.from.id && this.to.id){ if (this.from.id && this.to.id){
axios.get("http://localhost:3000/searchConnection", {params: {from: this.from.id, to:this.to.id}}).then(res => {this.connections = res.data;console.log(this.connections)}); axios.get("/searchConnection", {params: {from: this.from.id, to:this.to.id}}).then(res => {this.connections = res.data;console.log(this.connections)});
} }
}, },
toDate(string){ toDate(string){