We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
CORS处理需要后台配合,后台设置几个响应头信息就可以了,以express为例
CORS
express
app.get('/', (req, res) => { res.set('Access-Control-Allow-Origin', 'http://example.com'); // 允许的origin res.set('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH'); // 允许的HTTP方法 res.set('Access-Control-Allow-Headers', 'Content-Type'); // 支持的头信息字段,可以设置多种 res.set('Access-Control-Allow-Credentials', true); // 可选,表示是否允许发送Cookie res.send('hello') })
也可以写成一个中间件,放在你要跨域的路由之前即可.
当然使用了nginx的话,可以配置nginx,原理还是一样,也是设置这些头信息.你可以去查查相关资料哈!
@Craig-Cheng
Sorry, something went wrong.
非常感谢, 我试试看
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: