litestar-vite-plugin 0.18.3 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/index.js +10 -4
- package/package.json +1 -1
package/dist/js/index.js
CHANGED
|
@@ -113,6 +113,8 @@ function resolveLitestarPlugin(pluginConfig) {
|
|
|
113
113
|
})
|
|
114
114
|
);
|
|
115
115
|
};
|
|
116
|
+
const explicitServerOrigin = typeof userConfig.server?.origin === "string" && userConfig.server.origin.length > 0 ? userConfig.server.origin : void 0;
|
|
117
|
+
const shouldForceDirectServerOrigin = explicitServerOrigin !== void 0 || pythonDefaults?.proxyMode === "direct";
|
|
116
118
|
const devBase = pluginConfig.assetUrl.startsWith("/") ? pluginConfig.assetUrl : pluginConfig.assetUrl.replace(/\/+$/, "");
|
|
117
119
|
ensureCommandShouldRunInEnvironment(command, env, mode);
|
|
118
120
|
return {
|
|
@@ -129,7 +131,7 @@ function resolveLitestarPlugin(pluginConfig) {
|
|
|
129
131
|
assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0
|
|
130
132
|
},
|
|
131
133
|
server: {
|
|
132
|
-
origin:
|
|
134
|
+
origin: shouldForceDirectServerOrigin ? explicitServerOrigin ?? "__litestar_vite_placeholder__" : void 0,
|
|
133
135
|
// Auto-configure HMR to use a path that routes through Litestar proxy
|
|
134
136
|
// Note: Vite automatically prepends `base` to `hmr.path`, so we just use "vite-hmr"
|
|
135
137
|
// Result: base="/static/" + path="vite-hmr" = "/static/vite-hmr"
|
|
@@ -239,7 +241,8 @@ function resolveLitestarPlugin(pluginConfig) {
|
|
|
239
241
|
const address = server.httpServer?.address();
|
|
240
242
|
const isAddressInfo = (x) => typeof x === "object";
|
|
241
243
|
if (isAddressInfo(address)) {
|
|
242
|
-
|
|
244
|
+
const explicitServerOrigin = typeof userConfig.server?.origin === "string" && userConfig.server.origin.length > 0 ? userConfig.server.origin : void 0;
|
|
245
|
+
viteDevServerUrl = explicitServerOrigin ? explicitServerOrigin : resolveDevServerUrl(address, server.config, userConfig);
|
|
243
246
|
fs.mkdirSync(path.dirname(pluginConfig.hotFile), { recursive: true });
|
|
244
247
|
fs.writeFileSync(pluginConfig.hotFile, viteDevServerUrl);
|
|
245
248
|
setTimeout(async () => {
|
|
@@ -786,12 +789,15 @@ function resolveDevServerUrl(address, config, userConfig) {
|
|
|
786
789
|
const serverProtocol = config.server.https ? "https" : "http";
|
|
787
790
|
const protocol = clientProtocol ?? serverProtocol;
|
|
788
791
|
const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
|
|
792
|
+
const userHost = typeof userConfig.server?.host === "string" ? userConfig.server.host : null;
|
|
789
793
|
const configHost = typeof config.server.host === "string" ? config.server.host : null;
|
|
790
|
-
const remoteHost = process.env.VITE_ALLOW_REMOTE && !userConfig.server?.host ? "
|
|
794
|
+
const remoteHost = process.env.VITE_ALLOW_REMOTE && !userConfig.server?.host ? isIpv6(address) ? "[::1]" : "127.0.0.1" : null;
|
|
791
795
|
const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
|
|
792
|
-
let host = configHmrHost ?? remoteHost ?? configHost ?? serverAddress;
|
|
796
|
+
let host = configHmrHost ?? userHost ?? remoteHost ?? configHost ?? serverAddress;
|
|
793
797
|
if (host === "0.0.0.0") {
|
|
794
798
|
host = "127.0.0.1";
|
|
799
|
+
} else if (host === "::" || host === "[::]") {
|
|
800
|
+
host = "[::1]";
|
|
795
801
|
}
|
|
796
802
|
const configHmrClientPort = typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null;
|
|
797
803
|
const port = configHmrClientPort ?? address.port;
|