auto discover url in frontend

This commit is contained in:
philipredstone 2025-04-15 14:26:10 +02:00
parent 845bfb856e
commit 524dc010d0
5 changed files with 29 additions and 4 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
frontend/node_modules
frontend/dist
frontend/.env
frontend/bun.lockb
node_modules
dist
.env
bun.lockb

View File

@ -1,6 +1,10 @@
import axios from 'axios'; import axios from 'axios';
const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:5000/api'; const protocol = window.location.protocol;
const hostname = window.location.hostname;
const port = window.location.port;
const API_URL = protocol + '//' + hostname + (port ? ':' + port : '') + '/api';
// Configure axios // Configure axios
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;

View File

@ -1,6 +1,10 @@
import axios from 'axios'; import axios from 'axios';
const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:5000/api'; const protocol = window.location.protocol;
const hostname = window.location.hostname;
const port = window.location.port;
const API_URL = protocol + '//' + hostname + (port ? ':' + port : '') + '/api';
// Types // Types
export interface Network { export interface Network {

View File

@ -1,6 +1,10 @@
import axios from 'axios'; import axios from 'axios';
const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:5000/api'; const protocol = window.location.protocol;
const hostname = window.location.hostname;
const port = window.location.port;
const API_URL = protocol + '//' + hostname + (port ? ':' + port : '') + '/api';
// Types // Types
export interface Person { export interface Person {

View File

@ -1,6 +1,10 @@
import axios from 'axios'; import axios from 'axios';
const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:5000/api'; const protocol = window.location.protocol;
const hostname = window.location.hostname;
const port = window.location.port;
const API_URL = protocol + '//' + hostname + (port ? ':' + port : '') + '/api';
// Types // Types
export interface Relationship { export interface Relationship {