ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
--- >[info]ThinkPHP 的一些使用记录 **Nginx设置** (ver 6.0.3) ``` if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } ``` **跨域** 全局跨域 (ver 6.0.3) ``` // 开启全局跨域 \think\middleware\AllowCrossDomain::class ``` 路由跨域 (ver 6.0.3) ``` // 定义分组路由 Route::group('', function () { Route::rule('/', 'Index/index'); })->AllowCrossDomain(); ``` - 注意Nginx的Options拦截 (ver 6.0.3) ``` if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With'; add_header 'Access-Control-Max-Age' 1800; add_header 'Content-Type' 'text/html; charset=utf-8'; add_header 'Content-Length' 0; return 204; } ``` **THINK-SWOOLE NGINX 代理** ``` server{ listen 82 ; server_name 192.168.1.202; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Original-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:9501/; } } ```