如何将Express应用配置为支持长尾词的跨域访问?

2026-04-06 12:380阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计76个文字,预计阅读时间需要1分钟。

如何将Express应用配置为支持长尾词的跨域访问?

plaintextgistfile1.txt: 允许跨域访问

如何将Express应用配置为支持长尾词的跨域访问?

gistfile1.txt

//允许跨域访问 app.all('*', function(req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With'); res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); res.header('Content-Type', 'application/json; charset=utf-8'); if (req.method === 'OPTIONS') { res.sendStatus(200); } else { next(); } });

本文共计76个文字,预计阅读时间需要1分钟。

如何将Express应用配置为支持长尾词的跨域访问?

plaintextgistfile1.txt: 允许跨域访问

如何将Express应用配置为支持长尾词的跨域访问?

gistfile1.txt

//允许跨域访问 app.all('*', function(req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With'); res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); res.header('Content-Type', 'application/json; charset=utf-8'); if (req.method === 'OPTIONS') { res.sendStatus(200); } else { next(); } });