我正在尝试使用AWS API Gateway创建新服务,但我发现浏览器会自动调用OPTIONS方法以获取CORS信息.
问题是AWS API Gateway不提供配置CORS头的本机方式.
是否可以创建Lambda脚本以响应OPTIONS方法?
我正在使用基于新服务工作者的API在Web上使用推送通知,并具有以下用例:
鉴于Push API对userVisible的限制,有没有办法实现这种体验?
我正在使用(我看起来很像)我昨天从我的帐户获得的新Google Analytics跟踪代码.它使用了一些"全球站点标签".我把它放在我的顶部,正如GA指示的那样,但是我在加载页面时遇到了交叉原点错误,因此GA没有正确跟踪我的网站.
这是确切的消息:
来自'{my website}'的' https://www.googletagmanager.com/gtag/js?id= {my-id}' 访问脚本已被CORS政策阻止:'访问控制 - 允许 - Origin'标头的值为' http://www.googletagmanager.com ',不等于提供的来源.
导致此错误的脚本包含在内
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="//www.googletagmanager.com/gtag/js?id={my-id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{my-id}');
</script>
Run Code Online (Sandbox Code Playgroud)
上面的代码完全与Google Analytics一样,所以我不确定它为什么不起作用..
有人能帮忙吗?
Content-Disposition当我通过Angular服务访问它时,我无法获得特定的header().启用CORS并将Angular HTTPClient设置为检索所有标头.
Startup.cs
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
WebApiConfig.Register(config);
ConfigureOAuth(app, config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(config);
}
Run Code Online (Sandbox Code Playgroud)
fileController.cs
[Route("file/{idFile}")]
public HttpResponseMessage GetFile(string idFile)
{
string file;
byte[] file;
document = fileService.GetFile(idDFile, out fileName);
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(file)
};
result.Content.Headers.ContentDisposition =
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
{
FileName = nomeFile
};
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
return result;
}
Run Code Online (Sandbox Code Playgroud)
fileService.ts
getFile(fileId: number): Observable<Response> {
const url = `${urlBackEnd}/file/${fileId}`;
return this.http.get(url, { observe: 'response', responseType: 'blob' }) …Run Code Online (Sandbox Code Playgroud) 什么有效
我有一个简单的文字游戏我已经建立.它很棒.用户要求的一件事是单词有效性检查.我在AWS Lambda Proxy/Node.js端点上运行牛津词典api,当我通过浏览器访问APIGateway uri时,它运行良好.
我选择了AWS Lambda函数来保护我的Oxford API密钥,并且具有更直接的CORS控制.
采取的步骤
我在AWS APIGateway中启用了CORS,并在开发期间使用了"*"通配符.
我开始使用我的本地服务器@ 127.0.0.1对游戏进行编码.
遇到错误
我遇到了以下问题:
myproject.html:57跨源读取阻止(CORB)阻止跨源响应https://XXXXXXXXXXX.execute-api.us-east-2.amazonaws.com/prod/dictionary?word=help与MIME类型application/JSON.有关详细信息,请参阅https://www.chromestatus.com/feature/5629709824032768.getWord @ myproject.html:57(匿名)@ myproject.html:67
客户端代码
我正在使用简单的提取:
var base_url = "https://XXXXXXXXXXX.execute-api.us-east-2.amazonaws.com/prod/dictionary?word=";
getWord = function(word){
fetch(base_url+word, {
headers: {
'content-type': 'application/json'
},
method: 'GET',
mode: 'cors'
}).then(function(response) {
console.log(response);
});
}
Run Code Online (Sandbox Code Playgroud)
这个问题
我从未听说过CORB.我不明白什么是触发CORB,以及解决这个问题的步骤是什么.如何解决CORB问题?
javascript node.js cors aws-lambda cross-origin-read-blocking
我有一个服务器端呈现的Angular应用程序,我在其中使用ng2-adsense在某些路由上显示AdSense广告.我注意到大部分时间(并非所有时间),我的广告都没有显示,我在Chrome开发者控制台中收到警告说:
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.google.com/ads/measurement/l?ebcid=REDACTED with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
(anonymous) @ ads:1
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://googleads4.g.doubleclick.net/pcs/view?xai=REDACTED &sig=REDACTED &urlfix=1&adurl= with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://pagead2.googlesyndication.com/pagead/gen_204?id=sodar&v=24&t=2&bgai=REDACTED&bg=REDACTED with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
Run Code Online (Sandbox Code Playgroud)
我假设这是因为我的AdSense广告单元是动态加载的(必须是,广告只显示在客户端渲染上),而不是页面加载.
google-chrome adsense cors angular cross-origin-read-blocking
我正在使用 vanilla JavaScript 构建一个业余的富文本编辑器,并且 document.execCommand() 对于启用文本编辑器的核心功能至关重要。
例如粗体、斜体和无序列表命令:
Array.from(toolbarBtn).forEach(btn => {
btn.addEventListener('click', (e) => {
e.preventDefault();
if (e.target.id === "toolbar__btn--bold") {
format('bold');
}
if (e.target.id === "toolbar__btn--italic") {
format('italic');
}
if (e.target.id === "toolbar__btn--unorderedlist") {
format('insertunorderedlist');
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是,在 MDN Web Docs 上查找此命令时,我发现此命令已过时:
过时 此功能已过时。尽管它可能在某些浏览器中仍然有效,但不鼓励使用它,因为它可以随时被删除。尽量避免使用它。
所以,我想知道在 vanilla JavaScript 中是否有任何替代方法可以创建像 execCommand() 那样的所有富文本编辑器功能?
谷歌搜索没有给我任何结果,所以同时,我想知道,该方法被宣布已过时,但没有建议的替代方法怎么可能。
我有https://example.test & https://m.example.test 的apache 自我证书
浏览https://m.example.test 时,使用 php 'session.cookie_domain' 将 cookie 设置为基本域 '.example.test'。这在 Chrome、Firefox 或 Safari 版本 12 之前有效。但是,它在 Safari 13(iOS 13 或 Catalina)中不再起作用。
更奇怪的是,cookie 仍然设置为 Safari 13 上的基本域,我的生产机器为https://example.COM & https://m.example.COM
对于 COM 和 TEST 服务器,我有相同的 apache 服务器配置。在将我的 iOS 设备更新到 iOS 13 或 Catalina 之后的 MacOS 后,它只是停止在我的开发“.test”服务器上工作。Chrome、Firefox 仍然有效。即使连接到我的开发机器(通过代理)的旧 iOS 设备仍然将 cookie 存储到基本域“.example.test”。所以看起来它是特定于 Safari 13 的,并且只在“.test”域中。
我使用 Apple 的最新建议(最多 825 天等)为我的 .TEST 服务器创建了新证书,但没有任何区别。自签名证书似乎发生了一些变化。或者也许存在针对“.test”(非公共)域的新规则?它是特定于 Safari、“.test”非公共域或证书的内容。或者我什至没有想到的其他事情。
知道如何配置 Apache/Macosx/certificates 以便我仍然可以在开发 .test 域中使用 Safari 13 跨子域共享 cookie?谢谢。
我在互联网上找到了几篇关于如何衡量 Node.js 代码性能的文章和问题。但根据测量工具的不同,我得到的结果大约相差两倍。目标函数为:
let arr = [75, 283, 361, 168, 23, 489, 421, 95, 72, 380, 384, 470, 235, 465, 276, 26, 364, 416, 373, 184, 211, 239, 485, 18, 19, 252, 447, 6, 291, 324, 497, 352,
458, 201, 238, 116, 333, 163, 207, 417, 340, 431, 5, 269, 258, 178, 182, 295, 257, 434, 37, 372, 154, 223, 313, 80, 71, 229, 379, 181, 396, 281, 491, 58, 254,
359, 79, 175, 143, 214, 217, 148, 393, 246, …Run Code Online (Sandbox Code Playgroud) 我有一个API从我的 React 应用程序调用的端点。那API是在同一个域上。就像是:
https://www.example.com
https://www.example.com/api/update-something
Run Code Online (Sandbox Code Playgroud)
我曾经这样cross-fetch做过这个要求。
我希望Origin在我的服务器日志上看到一个标头。事实上,我很期待看到Origin: https://www.example.com。
但这是我得到的:
Origin: undefined
// AND I ALSO GET THESE HEADERS
"sec-fetch-dest":"empty",
"sec-fetch-mode":"cors",
"sec-fetch-site":"same-origin"
Run Code Online (Sandbox Code Playgroud)
他们的意思是什么?好像Origin已经查过了?
例如:如果我得到sec-fetch-site: cross-site它意味着调用是在另一个网站/域中生成的?那是对的吗?
参考:
Sec-Fetch-Site: cross-site
Sec-Fetch-Site: same-origin
Sec-Fetch-Site: same-site
Sec-Fetch-Site: none
Run Code Online (Sandbox Code Playgroud) same-origin-policy http-headers cors fetch-api sec-fetch-site
cors ×6
javascript ×4
angular ×2
aws-lambda ×2
cross-domain ×2
node.js ×2
adsense ×1
arrays ×1
c# ×1
cookies ×1
execcommand ×1
fetch-api ×1
http-headers ×1
owin ×1
performance ×1
push-api ×1
safari ×1
web-push ×1