【问题标题】:Deployed Laravel sanctum application not working anymore已部署的 Laravel sanctum 应用程序不再工作
【发布时间】:2021-06-12 17:42:33
【问题描述】:

我将 sanctum 用于我的 vue Axios 操作。我部署到我的共享主机并在 chrome 控制台中收到此错误:

GET http://foo.xyz/city401(未授权)

bootstrap.js:

window._ = require('lodash');

try {
    window.Popper = require('popper.js').default;
    window.$ = window.jQuery = require('jquery');

    require('bootstrap');
} catch (e) {}


window.axios.defaults.withCredentials = true;
window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

Axios 获取:

   getCity() {
            axios.get('/api/city')
                .then((response) => {
                    this.cities= response.data;
                })
                .catch(function (error) {
                    console.log(error);
                });

        },

当我将这个项目部署到我的共享主机中时,我的本地主机中一切正常,但没有任何效果,那么我如何在我的共享主机中运行它?

【问题讨论】:

    标签: laravel vue.js axios laravel-sanctum laravel-api


    【解决方案1】:

    我将以下代码添加到.env

    SANCTUM_STATEFUL_DOMAINS="foo.xyz"
    

    问题解决了。

    PS:

    foo.xyz 不是实际域,出于安全原因,我给了一个不同的域。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-03
      相关资源
      最近更新 更多