【发布时间】:2018-08-23 07:37:18
【问题描述】:
我使用 Vue.JS 作为前端,使用 Sails.JS 作为后端。
除了图片上传之外,一切都在我的本地机器和生产环境中运行。
我收到以下错误:
POST http://{mysailsdomain}/api/v1/upload 413 (Request Entity Too Large)
Failed To Load http://{mysailsdomain}/api/v1/upload: No 'Access-Control-Origin' header is present on the requested resource. Origin 'http://{myvuedomain}' is therfore not allowed access. The response had HTTP status code 413.
Uncaught (in promise) B {url: "http://{mysailsdomain}/api/v1/upload", ok: false, status: 0, statusText: "", headers: U, …}
Cross-Origin Read Blocking (CORB) blocked cross-origin response http://{mysailsdomain}/api/v1/upload with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
我的config/security.js
cors: {
allRoutes: true,
allowOrigins: '*',
allowCredentials: false,
},
我用谷歌搜索了这个错误,有人建议将此代码添加到我的config/http.js
bodyParser: (function () {
var opts = {limit:'50mb'};
var fn;
// Default to built-in bodyParser:
fn = require('skipper');
return fn(opts);
})
我添加了代码,但问题仍然存在。
这是我的production.js:
onlyAllowOrigins: [
'http://{myvuejsdashboard}',
'http://{myvuejsapp}'
]
我什至尝试将所有onlyAllowOrigins 注释掉,但仍然没有成功。
我正在使用 Sails v1.0.2。
【问题讨论】:
标签: ubuntu nginx vue.js sails.js digital-ocean