Skip to content

Commit

Permalink
fix: avoid error with API port 80
Browse files Browse the repository at this point in the history
  • Loading branch information
unmonoqueteclea committed Dec 1, 2024
1 parent 1592772 commit 16e5722
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
const BASE = import.meta.env.VITE_API_HOST || 'http://localhost'
const PORT = import.meta.env.VITE_API_PORT || '81'
const PREFIX = import.meta.env.VITE_API_PREFIX || ''
export const API_URL = BASE + ':' + PORT + PREFIX


const isDefaultPort = (url, port) => {
const isHttp = url.startsWith('http://') && port === '80';
const isHttps = url.startsWith('https://') && port === '443';
return isHttp || isHttps;
};

export const API_URL = isDefaultPort(BASE, PORT) ? BASE + PREFIX : BASE + ':' + PORT + PREFIX;

0 comments on commit 16e5722

Please sign in to comment.