所以这里是交易。我有一个带有“ satellizer ”和“ angular-jwt ”的离子应用程序,它与带有barryvdh/laravel-cors和tymondesigns/jwt-auth的 Laravel5 后端通信。在Homestead中运行这个组合可以很好地与ionic serve 结合使用。创建一个身份验证令牌并将其存储在 localStorage 中,并使用 Laravel 进行验证。此请求如下所示:
[IONIC SERVE] http://192.168.1.54:8100/#/auth
[POST] http://192.168.10.10/api/v1/authenticate?email=[email]&password=[password]
Returns [the_token]
[GET] http://192.168.10.10/api/v1/authenticate/user?token=[the_token]
Returns the user object from Laravel
一旦我将 api url 更改为我的实时服务器
[POST] http://domaintomyvps.com/api/v1/authenticate?email=[email]&password=[password]
Returns [the_token]
[GET] http://domaintomyvps.com/api/v1/authenticate/user?token=[the_token]
Returns {"error":"token_not_provided"}
身份验证工作正常,并返回了一个令牌。但是在发送获取请求时,我收到错误“token_not_provided”。
然后奇怪的事情发生了。当尝试来自 Chrome Postman 的相同请求时,令牌会验证并返回用户对象。
我的家园在 Ubuntu 的 VirtualBox 和 Nginx 中作为 Vagrant 运行。我的生产服务器是 Debian 和 Apache 在 VPS 上。Laravel 安装在设置和键方面是相同的。数据库完全相同(mysqldump)并且由于邮递员创建成功的结果而工作。
谁能指导我正确的方向或遇到同样的问题?您需要有关设置或代码的更多信息吗?