-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORS policy Access-Control-Allow-Private-Network
fails
#146
Comments
Access-Control-Allow-Private-Network
fails
Current temporary solution 1: Current temporary solution 2: Use file-based approach (Need manual refresh) import { defineConfig } from 'vite';
import monkey from 'vite-plugin-monkey';
export default defineConfig({
plugins: [
monkey({
entry: 'src/main.ts',
server: {
open: false,
},
userscript: {
icon: 'https://vitejs.dev/logo.svg',
namespace: 'npm/vite-plugin-monkey',
match: ['https://example.com/'],
},
}),
],
}); // ==UserScript==
// @name Monkey
// @namespace http://tampermonkey.net/
// @version 2024-04-04
// @match https://example.com/
// @grant none
// @require file://C:/Users/User/Desktop/monkey-project/dist/monkey-project.user.js
// ==/UserScript==
|
I have the same version of chrome as you do, but everything works fine in dev mode. Testing under Tampermonkey 5.0.1 with default settings. |
没看懂你想表达什么,如何复现你说的这个错误?
import { defineConfig } from 'vite';
import monkey from 'vite-plugin-monkey';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
{
name: 'set-headers',
apply: 'serve',
configureServer(server) {
server.middlewares.use((req, res, next) => {
res.setHeader(
'Access-Control-Allow-Private-Network',
'true'
);
next();
});
},
},
monkey({
entry: 'src/main.ts',
userscript: {
icon: 'https://vitejs.dev/logo.svg',
namespace: 'npm/vite-plugin-monkey',
match: ['https://example.com/'],
},
}),
],
}); |
谢谢,用这个方法解决了。我以为不是Vite服务器端的错误,而是Chrome就不让在别的地方执行localhost,原来是localhost的Header问题。看来是我孤陋寡闻了。 但是我很好奇为什么我以前用的时候没事,而且其他人也没事……。留这个Issue以供后人研究。 |
This does not seems to be the same as CSP policy #1 . Can you support file
@require
?好像现在 Chrome 更严了?
Chrome version: 123.0.6312.88
The text was updated successfully, but these errors were encountered: