使用内容类型放置请求:文本/HTML不起作用
我目前正在节点工作,我需要了解带有访问控制允许标头的请求方法,以下是我的代码,
import express from 'express';
import cors from 'cors';
const app = express();
var corsOptions = {
origin: '*',
optionsSuccessStatus: 200,
allowedHeaders:['Content-Type: text/html']
}
app.put("/puttest", (req, res) => {
console.log('in put');
res.send({ 'message': ' Hello world !!! app is listening on port '})
});
app.listen(3001, () => {
console.log('Listening to requests on 3001');
});
它不起作用?您能帮助我为什么当我提供任何内容类型时它不起作用:application/json或text/html?
I am currently working in node, I need to understand put request method with access control allow headers, Below is my code
import express from 'express';
import cors from 'cors';
const app = express();
var corsOptions = {
origin: '*',
optionsSuccessStatus: 200,
allowedHeaders:['Content-Type: text/html']
}
app.put("/puttest", (req, res) => {
console.log('in put');
res.send({ 'message': ' Hello world !!! app is listening on port '})
});
app.listen(3001, () => {
console.log('Listening to requests on 3001');
});
It is not working why? can you please help me why it is not working when I provide any content-type: application/JSON or text/HTML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论