diff --git a/.env.development b/.env.development index e065a5f..a7fabd6 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,6 @@ # 前缀为NEXT_PUBLIC_才可以被浏览器使用 -NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092 -NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 \ No newline at end of file +# NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092 +# NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 + +NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:80/todo-server +NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:80/security-server \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf index b3ebd00..f93c788 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -17,6 +17,18 @@ http { server { listen 3001; + # 设置允许跨域的域,* 表示允许任何域,也可以设置特定的域 + add_header 'Access-Control-Allow-Origin' '*'; + # 允许的方法 + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + # 允许的头信息字段 + add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type'; + # 缓存时间 + add_header 'Access-Control-Max-Age' 1728000; + # 预检请求的处理 + if ($request_method = 'OPTIONS') { + return 204; + } # 服务器名称 server_name localhost; # 访问日志路径 @@ -38,18 +50,6 @@ http { 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; @@ -60,17 +60,6 @@ http { 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/loading.tsx b/src/app/loading.tsx index 438d658..81f75b3 100644 --- a/src/app/loading.tsx +++ b/src/app/loading.tsx @@ -1,3 +1,5 @@ +import { Skeleton } from "antd"; + export default function Loading() { - return