Skip to content

[BUG] GM_xmlhttpRequest 无法绕过 CORS限制 #1473

@g9wp

Description

@g9wp

问题描述

脚本调用 GM_xmlhttpRequest 访问 localhost资源 出现 CORS限制

GM_xmlhttpRequest({
  url: 'http://localhost:xxx/xxx`,
  method: 'GET',
  onload: (res) => {
    console.log("res: ", res);
  },
  onerror: (e) => {
    console.error(e);
  }
});`

重现步骤

刚从tampermokey迁移过来的脚本,tm上运行正常的。

  1. 脚本有添加 //connect localhost
  2. 脚本设置>授权管理 选项下添加了 cors

脚本猫版本

1.3.2

操作系统以及浏览器信息

Windows10 , Chrome 148.0.7778.179(正式版本) (64 位)

补充信息 (选填)

Access to XMLHttpRequest at 'http://localhost:xx/...' from origin 'chrome-extension://xxx' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
localhost:xxx/xxx:1 Failed to load resource: net::ERR_FAILED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions