From 660fb0c6429313afb2945d60e00232f277738876 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Thu, 10 Apr 2025 19:10:57 +0100 Subject: [PATCH] Fixes and improvements --- .github/workflows/deploy.yaml | 2 -- client/src/constants/default.ts | 1 - deploy/nginx.conf | 53 ++++++++++++++------------------ deploy/touch-programming.service | 4 +-- server/main.go | 4 ++- 5 files changed, 28 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 30ec818..f16ea7c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -49,5 +49,3 @@ jobs: ssh-keyscan -H hazemkrimi.tech >> ~/.ssh/known_hosts rsync -avz --delete client/build/* deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/public rsync -avz --delete server/executable deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/api - # scp -r client/build deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/public - # scp server/executable deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/api diff --git a/client/src/constants/default.ts b/client/src/constants/default.ts index 149e113..8e517d5 100644 --- a/client/src/constants/default.ts +++ b/client/src/constants/default.ts @@ -1,7 +1,6 @@ export const KEYS_TO_DISABLE = [ 'Backspace', 'Shift', - 'Alt', 'Control', 'F1', 'F2', diff --git a/deploy/nginx.conf b/deploy/nginx.conf index 68c10ba..1cf9661 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -1,37 +1,30 @@ -events {} +server { + server_name touch-programming.hazemkrimi.tech; -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; + access_log /var/log/nginx/access.log; + root /var/www/touch-programming.hazemkrimi.tech/public; - server { - listen 80; - server_name touch-programming.hazemkrimi.tech; - access_log /var/log/nginx/access.log; - root /usr/share/nginx/html; + location / { + try_files $uri $uri/ /index.html; + } - location / { - try_files $uri $uri/ /index.html; - } + location /assets/ { + try_files $uri =404; + } - location /assets/ { - try_files $uri =404; - } + location ~* \.(?:css|js|ico|ttf|png|svg|webm) { + expires 1M; + access_log off; + add_header Cache-Control "public"; + } - location ~* \.(?:css|js|ico|ttf|png|svg|webm) { - expires 1M; - access_log off; - add_header Cache-Control "public"; - } - - location /api/ { - proxy_pass http://127.0.0.1:5000/; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_buffering off; - proxy_cache_bypass $http_upgrade; - proxy_http_version 1.1; - } + location /api/ { + proxy_pass http://127.0.0.1:5000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_buffering off; + proxy_cache_bypass $http_upgrade; + proxy_http_version 1.1; } } diff --git a/deploy/touch-programming.service b/deploy/touch-programming.service index c16178f..ce2e82e 100644 --- a/deploy/touch-programming.service +++ b/deploy/touch-programming.service @@ -2,8 +2,8 @@ Description=Touch Programming API Service [Service] -ExecStart=/usr/local/bin/touch-programming-api -WorkingDirectory=/usr/local/bin +ExecStart=/var/www/touch-programming.hazemkrimi.tech/api/executable +WorkingDirectory=/var/www/touch-programming.hazemkrimi.tech/api User=hazem Group=hazem LimitNOFILE=65536 diff --git a/server/main.go b/server/main.go index 271b188..9475221 100644 --- a/server/main.go +++ b/server/main.go @@ -26,7 +26,9 @@ func main() { ech := echo.New() - ech.Use(middleware.CORS()) + ech.Use(middleware.CORSWithConfig(middleware.CORSConfig{ + AllowOrigins: []string{"https://touch-programming.hazemkrimi.tech"}, + })) ech.GET("/generate", handlers.Generate)