mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-12-15 14:50:29 +08:00
docs:更新文档
This commit is contained in:
33
node_modules/vite/dist/node/server/serverPluginProxy.js
generated
vendored
Normal file
33
node_modules/vite/dist/node/server/serverPluginProxy.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.proxyPlugin = void 0;
|
||||
const url_1 = require("url");
|
||||
exports.proxyPlugin = ({ app, config, server }) => {
|
||||
if (!config.proxy) {
|
||||
return;
|
||||
}
|
||||
const debug = require('debug')('vite:proxy');
|
||||
const proxy = require('koa-proxies');
|
||||
const options = config.proxy;
|
||||
Object.keys(options).forEach((path) => {
|
||||
let opts = options[path];
|
||||
if (typeof opts === 'string') {
|
||||
opts = { target: opts };
|
||||
}
|
||||
opts.logs = (ctx, target) => {
|
||||
debug(`${ctx.req.method} ${ctx.req.oldPath} proxy to -> ${new url_1.URL(ctx.req.url, target)}`);
|
||||
};
|
||||
app.use(proxy(path, opts));
|
||||
});
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
if (req.headers['sec-websocket-protocol'] !== 'vite-hmr') {
|
||||
for (const path in options) {
|
||||
let opts = options[path];
|
||||
if (typeof opts === 'object' && opts.ws) {
|
||||
proxy.proxy.ws(req, socket, head, opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginProxy.js.map
|
||||
Reference in New Issue
Block a user