我一直在苦苦挣扎Access-Allow-Control-Origin
,我正在使用 Divshot。在我的移动应用程序中,我正在显示 WordPress 帐户的帖子,当我在浏览器中测试我的应用程序时,我可以看到这些帖子,但是一旦我在 Chrome for mobile 中打开该应用程序,我就无法看到这些帖子。根据我看到的,有些人有同样的问题,所以我需要在 Divshot 配置文件中使用 CORS。
在 Divshot 页面中,这就是他们所说的,但我不知道如何在我的应用程序中执行此操作
Custom Headers
If you need to set custom response headers for specific routes,
you can use the headers key in your configuration file:
{
"headers": {
"/cors-stuff/**": {
"Access-Control-Allow-Origin": "*"
},
"/scripts/**": {
"content-type": "text/javascript"
}
}
}
This can be useful for applying a content security policy, enforcing a different content-type, enabling cross-origin resource sharing (CORS), and more.
这就是我的配置文件中的内容
{
"name": "urbanetradio",
"root": "www",
"clean_urls": true,
"error_page": "error.html",
"headers": {
"Access-Control-Allow-Origin": "*",
"/js/**": {
"content-type": "text/javascript"
}
}
}
但我仍然没有任何好的结果。