Axios/InertiaJS 请求出现错误 401 (Heroku)
我在 heroku 上部署了我的网站。它有一个聊天系统并且可以在本地工作,但是当部署到 Heroku 时,返回所有用户的请求却返回错误 401。 GET https://website.herokuapp.com/api/user/me 401(未经授权)
我尝试从 api 路由中删除 auth:sanctum
但没有任何改变。 我将在下面给出一些代码。
Route::group(['middleware' => ['auth:sanctum']], function(){
Route::get('/user/me', [UserController::class, 'me'])->name('users.me');
});
public function me()
{
$userLogged = Auth::user();
return response()->json(
[
'user' => $userLogged,
],
Response::HTTP_OK
);
}
在网络控制台上,我在网络区域中收到一条消息:“未经身份验证。”
PS:如果有帮助,我使用本文进行部署:https://dev.to/rabeeaali/how-to-deploy-inertia-js-to-heroku-2cdn
I deployed my website on heroku. It has a chat system and works locally but when deploying to Heroku the request that returns me all the users returns instead an error 401.GET https://website.herokuapp.com/api/user/me 401 (Unauthorized)
I tried to remove the auth:sanctum
from the api route but nothing changed.
I'll give some of the code below.
Route::group(['middleware' => ['auth:sanctum']], function(){
Route::get('/user/me', [UserController::class, 'me'])->name('users.me');
});
public function me()
{
$userLogged = Auth::user();
return response()->json(
[
'user' => $userLogged,
],
Response::HTTP_OK
);
}
And on the web console I get a message: "Unauthenticated."
in the network area
PS: If it helps I used this article to deploy: https://dev.to/rabeeaali/how-to-deploy-inertia-js-to-heroku-2cdn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论