lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat
MIT License
1.39k stars 71 forks source link

不能从http请求127.0.0.1, #189

Closed last2004 closed 2 weeks ago

last2004 commented 2 weeks ago

出现如下错误,请大佬们指导一下,我已经试过,vite用https,添加server: { cors: true, https: true }, plugins: [ mkcert({source: 'coding'}), { name: 'set-headers', apply: 'serve', configureServer(server) { server.middlewares.use((req, res, next) => { // res.setHeader( // 'Access-Control-Allow-Private-Network', // 'true' // ); res.setHeader('Access-Control-Allow-Origin', 'http://xxx.cn'); res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); next(); }); }, },

错误是:
`Access to script at 'https://127.0.0.1:5173/__vite-plugin-monkey.entry.js' from origin 'http://xxx.cn' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.

`

last2004 commented 2 weeks ago

自己已经解决,打扰了。 EDGE 浏览器要在edge://flags/block-insecure-private-network-requests设置为disable