Closed last2004 closed 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(); }); }, },
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`.
`
自己已经解决,打扰了。 EDGE 浏览器要在edge://flags/ 的 block-insecure-private-network-requests设置为disable
edge://flags/
block-insecure-private-network-requests
出现如下错误,请大佬们指导一下,我已经试过,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(); }); }, },
`