+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import type { IncomingMessage, ServerResponse } from "node:http";
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
||||||
import type { ClientRequest, IncomingMessage as ProxyIncomingMessage } from "node:http";
|
import type { IncomingMessage as ProxyIncomingMessage } from "node:http";
|
||||||
import type { ProxyOptions } from "vite";
|
import type { ProxyOptions } from "vite";
|
||||||
import { MENU_SITE_ORIGIN, isMenuSlugProxyPath, stripMenuPreviewCacheParam, toMenuSitePath } from "./src/config/menuPreview";
|
import { MENU_SITE_ORIGIN, isMenuSlugProxyPath, stripMenuPreviewCacheParam, toMenuSitePath } from "./src/config/menuPreview";
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ export const getMenuSiteTargetUrl = (url: string) => {
|
|||||||
return `${MENU_SITE_ORIGIN}${menuPath}${stripMenuPreviewCacheParam(search)}`;
|
return `${MENU_SITE_ORIGIN}${menuPath}${stripMenuPreviewCacheParam(search)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createMenuSlugProxyAgent = () => ({
|
export const createMenuSlugProxyAgent = (): { configure: NonNullable<ProxyOptions["configure"]> } => ({
|
||||||
configure: (proxy: { on: (event: string, handler: (...args: unknown[]) => void) => void }) => {
|
configure: (proxy) => {
|
||||||
proxy.on("proxyReq", (proxyReq: ClientRequest) => {
|
proxy.on("proxyReq", (proxyReq) => {
|
||||||
proxyReq.removeHeader("origin");
|
proxyReq.removeHeader("origin");
|
||||||
});
|
});
|
||||||
proxy.on("proxyRes", stripPreviewPageHeaders);
|
proxy.on("proxyRes", stripPreviewPageHeaders);
|
||||||
|
|||||||
Reference in New Issue
Block a user