diff --git a/.env.development b/.env.development index 4ea0c46..e065a5f 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,3 @@ # 前缀为NEXT_PUBLIC_才可以被浏览器使用 -NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8090 -NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 -NEXT_PUBLIC_PRIVATE_KEY= \ No newline at end of file +NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092 +NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 \ No newline at end of file diff --git a/.env.production b/.env.production index 4691b0d..537f3c8 100644 --- a/.env.production +++ b/.env.production @@ -1 +1,2 @@ -NEXT_PUBLIC_TODO_REQUEST_URL=http://taskmanagerserver.com:8090 \ No newline at end of file +NEXT_PUBLIC_TODO_REQUEST_URL=http://www.huaruyu.com/todo-server +NEXT_PUBLIC_SECURITY_REQUEST_URL=http://www.huaruyu.com/security-server \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index e6df779..73f2133 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,4 +5,4 @@ COPY out /usr/share/nginx/html EXPOSE 3001 CMD ["nginx", "-g", "daemon off;"] # docker build -t task-manager-nginx . -# docker run -d -p 3001:3001 --restart unless-stopped -v ./out:/usr/share/nginx/html --name task-manager-nginx task-manager-nginx +# docker run -d -p 3001:3001 --network task-manager --restart unless-stopped -v ./out:/usr/share/nginx/html --name task-manager-nginx task-manager-nginx diff --git a/docker/nginx.conf b/docker/nginx.conf index 0056077..0a2c2bc 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -30,6 +30,48 @@ http { try_files $uri $uri.html $uri/ =404; # try_files $uri $uri/ =404; } + location ^~ /todo-server { + rewrite ^/todo-server/(.*)$ /$1 break; + proxy_pass http://huayu-platform-todo:8092; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + client_body_buffer_size 16k; + client_max_body_size 100M; + + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; + + # 如果请求方法为 OPTIONS,则直接返回 204 状态码 + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; + return 204; + } + } + location ^~ /security-server { + rewrite ^/security-server/(.*)$ /$1 break; + proxy_pass http://huayu-platform-security:8091; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + client_body_buffer_size 16k; + client_max_body_size 100M; + + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; + + # 如果请求方法为 OPTIONS,则直接返回 204 状态码 + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; + return 204; + } + } location /task/ { rewrite ^/task/(.*)$ /task/$1.html break; } diff --git a/src/app/favicon.ico b/src/app/favicon.ico deleted file mode 100644 index 718d6fe..0000000 Binary files a/src/app/favicon.ico and /dev/null differ diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b2e603d..57403f7 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -20,6 +20,10 @@ export default function RootLayout({