我在同一台服务器上有一个带有Laravel的Nuxt应用程序,而且由于我使用的是laravel /api,所以nginx正在使用/ API /api复制api.php。
这是我的装置。我只有一个简单的conf下的网站-可用的半链接网站-启用。
server {
listen 80;
root /var/www/html/nuxt-apt-front/dist;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /api{
alias "/var/www/html/laravel-api/public";
try_files $uri $uri/ @api;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/laravel-api/public/index.php;
}
}
location @api {
rewrite /api/(.*)$ /api/index.php?/$1 last;
}
include /etc/nginx/sites-available/*.conf;
}知道我可能做错了什么吗?
理想情况下,我想去/api买拉拉维尔
http://example.com/api/login/google现在,如果我有这个下面,它似乎是可行的。
http://example.com/api/api/login/googleapi.php实例
//通过谷歌登录。
Route::get('login/google', [GoogleAuthController::class, 'redirect']);
Route::get('login/google/callback', [GoogleAuthController::class, 'callback']);发布于 2021-11-03 20:56:51
如前所述,如果希望保持Nginx文件的原样,请更改RouteServiceProvider中的以下代码
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));对此:
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));这有点自我解释,前缀被添加到每个api路由/呼叫。通过删除它,它被简单地排除在外,并且只有一个附加于您的Nginx。
https://stackoverflow.com/questions/69831263
复制相似问题