大家好我是stackoverflow和Premise的新手,我不是NodeJs的专家;
低于我所做的
我从https://github.com/webix-hub/jet-start下载了webix jet 通过npm install在Ibm i(As400)中解压缩并安装webix jet(在Ibm中我们运行NodeJs V6.9.1) 作为webix Jet的依赖,有webpack我认为在安装步骤中也安装了webpack。 现在,如果在Webix Jet应用程序中我尝试调用在运行Webix Jet的其他域中运行的Web服务,我收到错误: 跨源请求已阻止:同源策略禁止在http://dom.com:10003/jsondemo/wcont.pgm读取远程资源。 (原因:缺少CORS标题'Access-Control-Allow-Origin') 我找了这个错误,解决方法似乎使服务器“Access-Control-Allow-Origin”。 我试图插入webpack.config.js文件 这条线为黑色..但错误的Cross-Origin Request Blocked仍然存在 有人可以帮我解决这个问题吗?
提前致谢
这里是我的完整webpack.config.js
var path = require("path");
var webpack = require(“webpack”);
module.exports = function(env){
var pack = require("./package.json");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var production = !!(env && env.production === "true");
var babelSettings = {
extends: path.join(__dirname, '/.babelrc')
};
var config = {
entry: "./sources/myapp.js",
output: {
path: path.join(__dirname, "codebase"),
publicPath:"/codebase/",
filename: "myapp.js"
},
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader?" + JSON.stringify(babelSettings)
},
{
test: /\.(svg|png|jpg|gif)$/,
loader: "url-loader?limit=25000"
},
{
test: /\.(less|css)$/,
loader: ExtractTextPlugin.extract("css-loader!less-loader")
}
]
},
resolve: {
extensions: [".js"],
modules: ["./sources", "node_modules"],
alias:{
"jet-views":path.resolve(__dirname, "sources/views"),
"jet-locales":path.resolve(__dirname, "sources/locales")
}
},
devServer: {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true' //just in case
}
},
plugins: [
new ExtractTextPlugin("./myapp.css"),
new webpack.DefinePlugin({
VERSION: `"${pack.version}"`,
APPNAME: `"${pack.name}"`,
PRODUCTION : production
})
]
};
if (production) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
test: /\.js$/
})
);
}
console.log('Config--> ' , config);
return config;
}