Skip to content

Commit 71304ff

Browse files
authored
fix: respect custom host in local dev (#1122)
Fixes #1121
1 parent df8f4b2 commit 71304ff

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

src/cli/commands/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function runQuirrelDev(
5656
}
5757

5858
await quirrel.server.app.jobs.updateCron("anonymous", {
59-
baseUrl: getApplicationBaseUrl(),
59+
baseUrl: getApplicationBaseUrl(config.host),
6060
crons: jobs,
6161
});
6262
});

src/client/config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function getOldEncryptionSecrets(): string[] | null {
8989
return JSON.parse(process.env.QUIRREL_OLD_SECRETS ?? "null");
9090
}
9191

92-
let developmentApplicationBaseUrl: string | undefined;
92+
let developmentApplicationPort: number | undefined;
9393

9494
function getNetlifyURL() {
9595
const siteId = process.env.SITE_ID;
@@ -108,12 +108,12 @@ function getVercelURL() {
108108
return process.env.VERCEL_URL;
109109
}
110110

111-
export function getApplicationBaseUrl(): string {
111+
export function getApplicationBaseUrl(host = "localhost"): string {
112112
const baseUrl =
113113
resolveEnvReference("QUIRREL_BASE_URL") ||
114114
getNetlifyURL() ||
115115
getVercelURL() ||
116-
developmentApplicationBaseUrl;
116+
`http://${host}:${developmentApplicationPort}`;
117117

118118
if (!baseUrl) {
119119
throw new Error("Please specify QUIRREL_BASE_URL.");
@@ -123,17 +123,17 @@ export function getApplicationBaseUrl(): string {
123123
}
124124

125125
export function registerDevelopmentDefaults({
126-
applicationBaseUrl,
126+
applicationPort,
127127
}: {
128-
applicationBaseUrl: string;
128+
applicationPort: number;
129129
}) {
130130
if (isProduction()) {
131131
return;
132132
}
133133

134-
if (developmentApplicationBaseUrl) {
134+
if (developmentApplicationPort) {
135135
return;
136136
}
137137

138-
developmentApplicationBaseUrl = applicationBaseUrl;
138+
developmentApplicationPort = applicationPort;
139139
}

src/netlify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { registerDevelopmentDefaults } from "./client/config";
22

33
registerDevelopmentDefaults({
4-
applicationBaseUrl: "http://localhost:8888",
4+
applicationPort: 8888,
55
});
66

77
export * from "./redwood";

src/next.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export {
3535
};
3636

3737
registerDevelopmentDefaults({
38-
applicationBaseUrl: "http://localhost:3000",
38+
applicationPort: 3000,
3939
});
4040

4141
export type Queue<Payload> = Omit<

src/nuxt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { registerDevelopmentDefaults } from "./client/config";
33
import * as connect from "./connect";
44

55
registerDevelopmentDefaults({
6-
applicationBaseUrl: "http://localhost:3000",
6+
applicationPort: 3000,
77
});
88

99
export function Queue<Payload>(

src/redwood.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export {
1818
};
1919

2020
registerDevelopmentDefaults({
21-
applicationBaseUrl: "http://localhost:8911",
21+
applicationPort: 8911,
2222
});
2323

2424
function decodeBase64(v: string): string {

src/remix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export {
2424
};
2525

2626
registerDevelopmentDefaults({
27-
applicationBaseUrl: "http://localhost:3000",
27+
applicationPort: 3000,
2828
});
2929

3030
export type Queue<Payload> = Omit<

src/sveltekit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { registerDevelopmentDefaults } from "./client/config";
1111
export { Job, EnqueueJobOptions, DefaultJobOptions, QuirrelJobHandler };
1212

1313
registerDevelopmentDefaults({
14-
applicationBaseUrl: "localhost:5173",
14+
applicationPort: 5173,
1515
});
1616

1717
interface SvelteEvent {

0 commit comments

Comments
 (0)