我在Node.js中构建了一个webchat应用程序,在PHP中构建了一个CMS应用程序。
现在我想通过一个<iframe>在CMS中使用网络聊天。两者都在同一个域上,端口不同。但是我不能访问CMS (PHP)中的webchat的<iframe> (节点JS)。
发布于 2018-10-11 10:52:53
如果您在Node:expressjs.html中使用Expressjs,则此链接可能会发出一些提示。
下面是一个简单的例子。
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get('/', function(req, res, next) {
// Handle the get for this route
});
app.post('/', function(req, res, next) {
// Handle the post for this route
});关于启用Node (即使没有express js)和PHP内部的CORS,有很多资源
https://stackoverflow.com/questions/52757145
复制相似问题