From 56108c7d379b89c5e8d6c717d801ac10d43a6fd1 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Tue, 25 Feb 2025 18:16:41 +0100 Subject: [PATCH] Update error handling and nginx conf wip --- client/src/pages/Typing/index.tsx | 5 ++++- nginx.conf | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 nginx.conf diff --git a/client/src/pages/Typing/index.tsx b/client/src/pages/Typing/index.tsx index b767223..508a2e4 100644 --- a/client/src/pages/Typing/index.tsx +++ b/client/src/pages/Typing/index.tsx @@ -28,7 +28,10 @@ function Typing() { `${import.meta.env.VITE_API_URL}/generate?lang=${lang}`, ); - if (!response.ok || !response.body) return; + if (!response.ok || !response.body) { + setError(true); + return; + } const reader = response.body.getReader(); const decoder = new TextDecoder(); diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9972efc --- /dev/null +++ b/nginx.conf @@ -0,0 +1,27 @@ +events {} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { + access_log /var/log/nginx/access.log; + + root /usr/share/nginx/html; + + location / { + try_files $uri $uri/ /index.html; + } + + location /assets/ { + try_files $uri =404; + } + + location /api/ { + proxy_pass http://localhost:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + } +}