Skip to content
Extraits de code Groupes Projets
Valider 299376ab rédigé par Brieuc Dubois's avatar Brieuc Dubois
Parcourir les fichiers

Fix docker build & technical-debt

parent 7198a51c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -65,7 +65,7 @@ app.add_middleware( ...@@ -65,7 +65,7 @@ app.add_middleware(
allow_headers=["*"], allow_headers=["*"],
) )
apiRouter = APIRouter(prefix="/api") apiRouter = APIRouter(prefix="/tmp-api")
v1Router = APIRouter(prefix="/v1") v1Router = APIRouter(prefix="/v1")
authRouter = APIRouter(prefix="/auth", tags=["auth"]) authRouter = APIRouter(prefix="/auth", tags=["auth"])
usersRouter = APIRouter(prefix="/users", tags=["users"]) usersRouter = APIRouter(prefix="/users", tags=["users"])
......
...@@ -11,6 +11,7 @@ services: ...@@ -11,6 +11,7 @@ services:
- external - external
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
#- "traefik.http.routers.frontend.rule=Host(`languagelab.be`)"
- "traefik.http.routers.frontend.rule=Host(`languagelab.sipr.ucl.ac.be`)" - "traefik.http.routers.frontend.rule=Host(`languagelab.sipr.ucl.ac.be`)"
- "traefik.http.routers.frontend.tls=true" - "traefik.http.routers.frontend.tls=true"
- "traefik.http.services.frontend.loadbalancer.server.port=8080" - "traefik.http.services.frontend.loadbalancer.server.port=8080"
...@@ -25,7 +26,7 @@ services: ...@@ -25,7 +26,7 @@ services:
- ADMIN_EMAIL=${LANGUAGELAB_ADMIN_EMAIL} - ADMIN_EMAIL=${LANGUAGELAB_ADMIN_EMAIL}
- ADMIN_PASSWORD=${LANGUAGELAB_ADMIN_PASSWORD} - ADMIN_PASSWORD=${LANGUAGELAB_ADMIN_PASSWORD}
- CALCOM_SECRET=${LANGUAGELAB_CALCOM_SECRET} - CALCOM_SECRET=${LANGUAGELAB_CALCOM_SECRET}
- ALLOWED_ORIGINS=https://languagelab.sipr.ucl.ac.be - ALLOWED_ORIGINS=https://languagelab.be,https://api.languagelab.be
volumes: volumes:
- /mnt/data/languagelab/backend:/data - /mnt/data/languagelab/backend:/data
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
...@@ -36,7 +37,8 @@ services: ...@@ -36,7 +37,8 @@ services:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.backend.tls=true" - "traefik.http.routers.backend.tls=true"
- "traefik.http.services.backend.loadbalancer.server.port=8000" - "traefik.http.services.backend.loadbalancer.server.port=8000"
- "traefik.http.routers.backend.rule=Host(`languagelab.sipr.ucl.ac.be`) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/openapi.json`))" #- "traefik.http.routers.backend.rule=Host(`languagelab.be`) && (PathPrefix(`/tmp-api`) || PathPrefix(`/docs`) || PathPrefix(`/openapi.json`))"
- "traefik.http.routers.backend.rule=Host(`languagelab.sipr.ucl.ac.be`) && (PathPrefix(`/tmp-api`) || PathPrefix(`/docs`) || PathPrefix(`/openapi.json`))"
traefik: traefik:
container_name: traefik container_name: traefik
......
...@@ -6,3 +6,9 @@ declare module 'emoji-picker-element'; ...@@ -6,3 +6,9 @@ declare module 'emoji-picker-element';
interface ImportMetaEnv { interface ImportMetaEnv {
VITE_API_URL: string; VITE_API_URL: string;
} }
declare global {
interface RequestInit {
duplex?: string;
}
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "VITE_API_URL=http://127.0.0.1:5173/api VITE_APP_URL=http://127.0.0.1:5173 VITE_WS_URL=ws://127.0.0.1:8000/api/v1/ws vite dev --host 127.0.0.1", "dev": "VITE_API_URL=http://127.0.0.1:8000/tmp-api VITE_APP_URL=http://127.0.0.1:5173 VITE_WS_URL=ws://127.0.0.1:8000/tmp-api/v1/ws vite dev --host 127.0.0.1",
"build": "vite build", "build": "vite build",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
......
import { type Handle, type RequestEvent } from '@sveltejs/kit'; import { type Handle, type RequestEvent } from '@sveltejs/kit';
import { jwtDecode } from 'jwt-decode'; import { jwtDecode } from 'jwt-decode';
import { type JWTContent } from '$lib/utils/login'; import { type JWTContent } from '$lib/utils/login';
import config from '$lib/config';
const API_BASE_URL = 'http://127.0.0.1:8000/api/v1';
const PROXY_PATH = '/api'; const PROXY_PATH = '/api';
const handleApiProxy = async (event: RequestEvent, cookies: { name: string; value: string }[]) => { const handleApiProxy = async (event: RequestEvent, cookies: { name: string; value: string }[]) => {
const strippedPath = event.url.pathname.substring(PROXY_PATH.length); const strippedPath = event.url.pathname.substring(PROXY_PATH.length);
const urlPath = `${API_BASE_URL}${strippedPath}${event.url.search}`; console.log('redirect to ', `${config.API_URL}/v1${strippedPath}${event.url.search}`);
const urlPath = `${config.API_URL}/v1${strippedPath}${event.url.search}`;
const proxiedUrl = new URL(urlPath); const proxiedUrl = new URL(urlPath);
event.request.headers.delete('connection'); event.request.headers.delete('connection');
event.request.headers.set('cookie', cookies.map((c) => `${c.name}=${c.value}`).join('; ')); event.request.headers.set('cookie', cookies.map((c) => `${c.name}=${c.value}`).join('; '));
return event.fetch(proxiedUrl.toString(), event.request).catch((err: any) => { return fetch(proxiedUrl.toString(), {
body: event.request.body,
method: event.request.method,
headers: event.request.headers,
// @ts-ignore: Duplex is missing
duplex: 'half'
}).catch((err: any) => {
console.log('Could not proxy API request: ', err); console.log('Could not proxy API request: ', err);
throw err; throw err;
}); });
...@@ -28,6 +35,7 @@ export const handle: Handle = async ({ event, resolve }) => { ...@@ -28,6 +35,7 @@ export const handle: Handle = async ({ event, resolve }) => {
const cookies = event.cookies.getAll(); const cookies = event.cookies.getAll();
if (event.url.pathname.startsWith(PROXY_PATH)) { if (event.url.pathname.startsWith(PROXY_PATH)) {
console.log(event.url.pathname);
return await handleApiProxy(event, cookies); return await handleApiProxy(event, cookies);
} }
......
export default { export default {
API_URL: import.meta.env.VITE_API_URL || 'https://languagelab.sipr.ucl.ac.be/api', API_URL: import.meta.env.VITE_API_URL || 'https://languagelab.sipr.ucl.ac.be/tmp-api',
API_PROXY: import.meta.env.VITE_API_PROXY || 'https://languagelab.sipr.ucl.ac.be:8000', API_PROXY: import.meta.env.VITE_API_PROXY || 'https://languagelab.sipr.ucl.ac.be/tmp-api',
APP_URL: import.meta.env.VITE_APP_URL || 'https://languagelab.sipr.ucl.ac.be', APP_URL: import.meta.env.VITE_APP_URL || 'https://languagelab.be',
WS_URL: import.meta.env.VITE_WS_URL || 'wss://languagelab.sipr.ucl.ac.be/api/v1/ws', WS_URL: import.meta.env.VITE_WS_URL || 'wss://languagelab.sipr.ucl.ac.be/tmp-api/v1/ws',
//API_URL: import.meta.env.VITE_API_URL || 'https://languagelab.be/tmp-api',
//API_PROXY: import.meta.env.VITE_API_PROXY || 'https://languagelab.be/tmp-api',
//WS_URL: import.meta.env.VITE_WS_URL || 'wss://languagelab.be/tmp-api/v1/ws',
//
//API_URL: import.meta.env.VITE_API_URL || 'https://api.languagelab.be/api',
//API_PROXY: import.meta.env.VITE_API_PROXY || 'https://api.languagelab.be',
//WS_URL: import.meta.env.VITE_WS_URL || 'wss://api.languagelab.be/api/v1/ws',
//
// 1 week - 2 hours // 1 week - 2 hours
WEEKLY_SURVEY_INTERVAL: (7 * 24 - 2) * 60 * 60 * 1000, WEEKLY_SURVEY_INTERVAL: (7 * 24 - 2) * 60 * 60 * 1000,
LEARNING_LANGUAGES: { LEARNING_LANGUAGES: {
......
/** @type {import('tailwindcss').Config} */ import daisyui from 'daisyui';
export default { export default {
content: ['./src/**/*.{html,js,svelte,ts}'], content: ['./src/**/*.{html,js,svelte,ts}'],
theme: { theme: {
...@@ -8,7 +9,7 @@ export default { ...@@ -8,7 +9,7 @@ export default {
} }
} }
}, },
plugins: [require('daisyui')], plugins: [daisyui],
daisyui: { daisyui: {
themes: [ themes: [
'bumblebee', 'bumblebee',
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter