简体   繁体   English

好像浏览器处于隐身模式一样发出获取请求?

[英]Making a get request as if the browser is in incognito mode?

I'm making a get request using fetch to a given url that lets say is joe.com/123.我正在使用 fetch 向给定的 url 发出获取请求,可以说是 joe.com/123。 The contents are different whenever I'm logged into the website versus when I'm logged out of the website.当我登录网站和退出网站时,内容是不同的。 How do I ensure that anytime I make the request to the url, even if I am logged in, it returns a result that is consistent with the logged out response?如何确保无论何时我向 url 发出请求,即使我已登录,它也会返回与注销响应一致的结果? I have tried adding to the fetch request the cache parameter, setting it "no-cache" and "no-store" but both values did not help - it returns the logged in response.我尝试将缓存参数添加到获取请求中,将其设置为“no-cache”和“no-store”,但两个值都没有帮助 - 它返回登录的响应。

Tried both - fetch(bruh, {cache:"no-cache"}) & fetch(bruh, {cache:"no-store"})都试过了 - fetch(bruh, {cache:"no-cache"}) & fetch(bruh, {cache:"no-store"})

    bruh = window.location.toString();
    bro = await fetch(bruh).then(result =>result.text()).then(text=>text);

I figured it out.我想到了。 Here's the answer for future people that will surely have this question.这是未来肯定会有这个问题的人的答案。

fetch('https://example.com', {credentials: 'omit'});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript HTTP 请求不在隐身模式下 - JavaScript HTTP Request Not in Incognito Mode 让用户在浏览时使用隐身模式而不是正常浏览 - Making users use incognito mode in browsing instead of normal browsing Angular:如何配置“ ng serve”命令以打开隐身模式浏览器? - Angular: How to configure 'ng serve' command to open an Incognito Mode browser? 用于跨浏览器检测隐身模式的Javascript(私人浏览) - Javascript For Cross Browser Detection of Incognito Mode (Private Browsing) 有没有办法通过使用 javascript 检查浏览器是否在隐身模式下工作? - Is there any way to check browser works with incognito mode or not by using javascript? 我可以在浏览器选项卡的隐身模式下运行 html 代码吗? [等候接听] - Can i run the html code on incognito mode of browser tab? [on hold] chrome隐身模式下的LocalStorage - LocalStorage in chrome Incognito Mode HTTP GET请求在正常会话上有效,但在“隐身”会话中无效 - HTTP GET request working on normal session but not in 'incognito' session sessionStorage.getItem('key')可以触发异常吗? 隐身模式? 任何旧的手机浏览器? - Can sessionStorage.getItem('key') trigger an exception? incognito mode? Any old mobile phone browser? 如何创建一个 hash,即使在浏览器使用指纹 js2 刷新后,它在隐身模式下也保持不变? - How to create a hash that in incognito mode stays the same even after browser refreshs with fingerprintjs2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM