云存储-AngularJS视图的请求资源上没有'Access-Control-Allow-Origin'标头 [英] Cloud Storage - No 'Access-Control-Allow-Origin' header is present on the requested resource for AngularJS view

查看:92
本文介绍了云存储-AngularJS视图的请求资源上没有'Access-Control-Allow-Origin'标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Chrome开发者工具,获取我的html部分的请求具有原始标头 https://site-name -here.com 并请求标头GET.
我将以下JSON文件设置为我的存储桶:

According to Chrome dev tools, my requests to get my html partials have the origin header https://site-name-here.com and request header GET.
I have the following JSON file set to my bucket:

[
    {
      "origin": ["https://site-name-here.com"],
      "responseHeader": ["content-type"],
      "method": ["GET"],
      "maxAgeSeconds": 3600
    }
]

但是,每当angular尝试获取视图时,都会出现以下错误:XMLHttpRequest cannot load https://storage.googleapis.com/bucket-name/view-path.html?. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://site-name-here.com' is therefore not allowed access.

However, whenever angular tries to get the view, I get the following error: XMLHttpRequest cannot load https://storage.googleapis.com/bucket-name/view-path.html?. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://site-name-here.com' is therefore not allowed access.

我也正在从Cloud Storage提供javascript和css文件,但是它们工作正常,我认为是因为CSS没有CORS限制,并且我在Angular中使用$ sceDelegateProvider.resourceUrlWhitelist()作为脚本?

I am also serving javascript and css files from Cloud Storage, but they're working fine, I assume because CSS doesn't have CORS restrictions and I'm using $sceDelegateProvider.resourceUrlWhitelist() in Angular for the scripts?

编辑:现在,我假设已缓存了某些内容,并且正在为我提供旧版本.

Edit: Working now, I'm assuming something was cached and it was serving me an old version.

推荐答案

实际上,清除浏览器或其他中间服务的缓存后,就可以解决此类问题.

In fact, this type of issue can potentially be resolved upon clearing the browser or other intermediary service’s cache.

如果您的应用程序在Google App Engine实例上运行,则可以通过重新部署该应用程序的新版本来清除其中间缓存.或者,也可以为网络代理和浏览器中缓存的文件设置default_expiration或简单的expiration(请参阅此静态缓存到期

In case your application is running on a Google App Engine instance, it is possible to clear its intermediate cache by redeploying a new version of the app. Alternatively, it may be also possible to set a default_expiration or simple expiration of files cached within web proxies and browsers (see this Static cache expiration section of the app.yaml reference for more information).

这篇关于云存储-AngularJS视图的请求资源上没有'Access-Control-Allow-Origin'标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆