After configuring the domain name2

This commit is contained in:
Your Name 2026-10-31 20:18:10 +02:00
parent 4b669222f0
commit 7b6c6fd564
2 changed files with 40 additions and 2 deletions

View File

@ -1,8 +1,21 @@
# www → apex (évite double origine / cookies)
server {
listen 443 ssl;
http2 on;
server_name ${PREDIQO_DOMAIN_WWW};
ssl_certificate /etc/letsencrypt-prediqo/live/${PREDIQO_CERT_NAME}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt-prediqo/live/${PREDIQO_CERT_NAME}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
return 301 https://${PREDIQO_DOMAIN}$request_uri;
}
# Tloto / Prediqo — HTTPS sur 443 (URL publique sans port : https://${PREDIQO_DOMAIN})
server {
listen 443 ssl;
http2 on;
server_name ${PREDIQO_DOMAIN} ${PREDIQO_DOMAIN_WWW};
server_name ${PREDIQO_DOMAIN};
ssl_certificate /etc/letsencrypt-prediqo/live/${PREDIQO_CERT_NAME}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt-prediqo/live/${PREDIQO_CERT_NAME}/privkey.pem;

View File

@ -6,7 +6,32 @@ import axios, { AxiosError } from 'axios';
import { readAuth, writeAuth, clearAuth } from '../auth/tokenStorage';
import { getOrCreateVisitorToken } from '../../features/support/utils/visitorToken';
const baseURL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:4000';
/**
* In production behind the VPS gateway, prefer same-origin (`''`) so
* https://tloto.net and https://www.tloto.net both call `/api/...` on the
* current host (avoids stale :9443 builds and www↔apex CORS failures).
*/
function resolveApiBaseUrl(): string {
const configured = String(import.meta.env.VITE_API_BASE_URL ?? '').trim();
if (import.meta.env.DEV) {
return configured || 'http://localhost:4000';
}
if (!configured || configured === 'same-origin') {
return '';
}
if (typeof window !== 'undefined') {
try {
if (new URL(configured).host !== window.location.host) {
return '';
}
} catch {
return '';
}
}
return configured.replace(/\/$/, '');
}
const baseURL = resolveApiBaseUrl();
/** Preconfigured Axios instance targeting the backend API with JSON headers. */
export const api = axios.create({