
express框架
&蓝天之约&
这个作者很懒,什么都没留下…
展开
-
The value of the ‘Access-Control-Allow-Origin‘ header in the response must not be the wildcard问题
app.use('/', (req, res, next) => { res.header('Access-Control-Allow-Origin', req.header('Origin')); res.header('Access-Control-Allow-Method', 'get,post'); res.header('Access-Control-Allow-Credentials', true) next()})在跨域请求中携带Cookie的问题.原创 2021-05-13 13:33:40 · 818 阅读 · 0 评论 -
浏览器不渲染html而是返回html代码的问题
在用express框架创建服务器后,发现有时在服务器端访问html代码时,浏览器不进行解析而是直接显示了html代码,查了一下原因!在express框架中,官方推荐jade引擎,而我打开的html文件,渲染时就有可能会出现问题,不是全部都有问题,这个有待考究,说一下解决方法:在允许跨域时设置的app.all()中,将头部res.header('content-type')注释掉:app.all('*', function(req, res, next) { res.header("Ac原创 2021-04-11 16:22:29 · 2040 阅读 · 1 评论