我的 Web 应用程序(进一步是 myApp)嵌入在单个第三方网页的 iframe 中。MyApp 设置 cookieSet-Cookie: JSESSIONID=38FE580EE7D8CACA581532DD37A19182; Path=/myapi; Secure; HttpOnly以维护用户会话。前一段时间它停止在 Chrome 中工作,因为https://blog.chromium.org/2020/02/samesite-cookie-changes-in-february.html更新更改了处理没有SameSite属性的cookie 的默认行为from Noneto Lax。
我将从 myApp 主机发送 cookie 与SameSite=None; Secure. X-CSRF-TOKEN每个响应中还包含标头。myApp javascript 获取X-CSRF-TOKEN并将其放入对 myApp 主机的每个 XHR 请求的标头中。这足以防止CSRF攻击吗?
是否应该Access-Control-Allow-Origin: third-party-webpage在响应中添加标头?
我正在尝试向此端点发送请求:https://9gag.com/v1/group-posts/group/default/type/trending获取 9gag 帖子数据。
在邮递员和 chrome 上运行良好,但是当我尝试axios从 Node.js使用时,它响应403(并读取返回的 DOM,它认为它要求我输入验证码),当我尝试使用 发送请求时node-fetch,它响应与200帖子数据(这是正确的)。
问题是,为什么node-fetch工作正常但axios没有?
这是我用于测试的代码:
import axios from "axios";
import fetch from "node-fetch";
const URL = "https://9gag.com/v1/group-posts/group/default/type/trending";
// Inside async function
await fetch(URL); // Responded with 200 and json data
await axios(URL); // Responded with 403 and HTML DOM, axios.get() also gives the same result
Run Code Online (Sandbox Code Playgroud) 我有一个 React 应用程序,它是用“create-react-app”创建的(我也使用 jsdom NPM 包),出于某种原因,该应用程序仅在 Firefox 中在加载时引发错误(在 Chrome 和 Edge 中工作正常)。
这是错误:
ReferenceError: SharedArrayBuffer is not defined
./node_modules/jsdom/node_modules/webidl-conversions/lib/index.js
C:/Or/Web/WorldCovid/WorldCovid/node_modules/jsdom/node_modules/webidl-conversions/lib/index.js:347
344 |
345 | const abByteLengthGetter =
346 | Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
> 347 | const sabByteLengthGetter =
348 | Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
349 |
350 | function isNonSharedArrayBuffer(V) {
Run Code Online (Sandbox Code Playgroud)
经过一番谷歌搜索,我发现:
“为了使SharedArrayBuffer在Firefox中,去about:config中和javascript.options.shared_memory偏好设置为true”(https://github.com/ggerganov/kbd-audio/issues/9)
的问题是它已经启用为true。
以前有人遇到过这个问题吗?谢谢。
更新:
尝试转换为:
const shared = new SharedArrayBuffer(1024);
const abByteLengthGetter =
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
const sabByteLengthGetter =
Object.getOwnPropertyDescriptor(shared.prototype, "byteLength").get;
Run Code Online (Sandbox Code Playgroud)
仍然得到相同的错误(与 SharedArrayBuffer 对象不同的行)。
javascript firefox reactjs cross-origin-embedder-policy cross-origin-opener-policy
我正在制作一个简单的项目,在 React 中使用 WebRTC 和 typescript。
我正在关注MDN HTMLMediaElement.captureStream()。
const vid: HTMLVideoElement | null = document.querySelector("video");
if (vid) {
vid.captureStream();
}
.
.
.
<video id="myVid"></video>
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误
Property 'captureStream' does not exist on type 'HTMLVideoElement'.ts(2339)
Run Code Online (Sandbox Code Playgroud)
我什至尝试过,
const vid: HTMLMediaElement | null = document.querySelector("video");
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么??
我试过
const videoCont = useRef<HTMLVideoElement>(null);
var URL = window.URL || window.webkitURL
const fileURL = URL.createObjectURL(e)
if (videoCont.current) {
videoCont.current.src = fileURL;
videoCont.current.play = async () => {
const mediaStream = videoCont.current?.captureStream();
}
}
Run Code Online (Sandbox Code Playgroud)
还是同样的错误, …
我使用lighttpd提供静态内容(html、css 和 js) 。我想使用带有 python 的 wsgi 应用程序从本地主机上托管的服务器调用 api。当我尝试从前端调用 api(使用 ajax 和 jquery 库)时,出现以下错误。

我正在通过勇敢的浏览器访问该网站。出于测试目的,如何禁用此“跨源读取阻止 (CORB) 阻止跨源响应”功能?
我们使用puppeteer,有时还使用playwright来运行一些集成测试。我们模拟了一些目标页面的脚本依赖项,这会导致子资源完整性哈希不匹配。
无法使用计算的 SHA 在资源“http://localhost:3000/static/third-party/adobe-target/at-js/2.4.0-cname/at.js”的“integrity”属性中找到有效摘要-256 完整性'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='。资源已被封锁。”
有没有办法通过标志或配置属性禁用完整性哈希检查?
google-chrome chromium subresource-integrity puppeteer playwright
我正在开发 Nodejs 项目和哈巴狗模板。当我登录邮递员时,会发送 Cookie,但是当我使用 Chrome 或任何其他浏览器时,它不会显示 Cookie
const signToken = (id) => {
return jwt.sign({ id }, process.env.JWT_SECRET, {
expiresIn: process.env.JWT_EXPIRES_IN,
})
}
const createSendToken = (user, statusCode, req, res) => {
const token = signToken(user._id)
res.cookie('jwt', token, {
expires: new Date(
Date.now() + process.env.JWT_COOKIE_EXPIRES_IN * 24 * 60 * 60 * 1000
),
httpOnly: true,
})
res.status(statusCode).json({
status: 'success',
token,
data: {
user,
},
})
}
Run Code Online (Sandbox Code Playgroud)
我也在使用npm 的cookie-parser和cors
app.use(
cors({
credentials: true,
})
)
Run Code Online (Sandbox Code Playgroud)
我尝试过使用 cors,没有任何选项。还是不行。 …
我有一个有 2 个成员的结构,它依赖第一个成员来计算第二个成员的值。
struct SomeStruct
{
int memberA = 0;
int memberB = memberA + 5;
};
int main()
{
auto SomeLambda = []()
{
SomeStruct x;
x = SomeStruct{};
};
SomeStruct x;
x = SomeStruct{};
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想重新分配该结构以重新初始化它并重用变量名称。我可以在常规函数中执行此操作,但是如果我在 lambda 中执行此操作,则会出现以下编译错误。
main.cpp(12): error C2512: 'SomeStruct': no appropriate default constructor available
main.cpp(12): note: Invalid aggregate initialization
Run Code Online (Sandbox Code Playgroud)
如果我消除成员之间的相互依赖性,代码可以正常编译。
struct SomeStruct
{
int memberA = 0;
int memberB = 5;
};
Run Code Online (Sandbox Code Playgroud)
如果我更改 lambda 内的赋值以使用括号而不是大括号,这也允许代码编译。
SomeStruct x;
x = SomeStruct();
Run Code Online (Sandbox Code Playgroud)
然而 lambda 之外的赋值仍然使用大括号。 …
我正在开发一个具有 FastAPI 后端和 React 前端的项目。当通过调用后端时,fetch我有时会得到以下信息:
Access to fetch at 'http://localhost:8000/get-main-query-data' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Run Code Online (Sandbox Code Playgroud)
这种情况经常发生,我可以调用一个端点,然后抛出错误。有时所有端点都会抛出错误
Middleware我已经这样设置了main.py:(也在这一行)
Access to fetch at 'http://localhost:8000/get-main-query-data' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. …Run Code Online (Sandbox Code Playgroud) 我有一个托管在使用 CanvasKit 渲染的 Firebase Hosting 上的 Flutter Web 项目,但我无法使其加载 Xano CDN 中托管的外部图像或加载 GooglePlaces API 结果(自动编译)。我阅读了许多其他解决方案(例如这个或这个或这个),但没有一个有效。我还在Google Cloud 上配置了 CORS。
这是我的firebase.json文件:
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "*",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
在 index.html 中,我在标签之前附加了以下脚本</body>:
<!-- Firebase -->
<script type="module">
// Import …Run Code Online (Sandbox Code Playgroud) reactjs ×3
cookies ×2
javascript ×2
node.js ×2
python ×2
ajax ×1
axios ×1
brave ×1
c++ ×1
chromium ×1
cross-origin-embedder-policy ×1
csrf ×1
dart ×1
express ×1
fastapi ×1
fetch-api ×1
firebase ×1
firefox ×1
flutter-web ×1
html ×1
node-fetch ×1
npm ×1
playwright ×1
pug ×1
puppeteer ×1
samesite ×1
typescript ×1
visual-c++ ×1
webrtc ×1