Skip to content

Commit aed4aa0

Browse files
committed
fix: dynamically assign port in experiments index route
1 parent 9ecf50b commit aed4aa0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

examples/experiments/src/routes/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Title } from "@solidjs/meta";
22
import { json } from "@solidjs/router";
33
import { clientOnly, GET } from "@solidjs/start";
44
import { getServerFunctionMeta } from "@solidjs/start/server";
5-
import { getRequestEvent } from "solid-js/web";
5+
import { getRequestEvent, isServer } from "solid-js/web";
66
import Counter from "~/components/Counter";
77
const BreaksOnServer = clientOnly(() => import("~/components/BreaksOnServer"));
88

@@ -22,7 +22,8 @@ export default function Home() {
2222
console.log(v);
2323
console.log(await v.hello);
2424
});
25-
fetch(`http://localhost:5173/${import.meta.env.SERVER_BASE_URL}/unknown`, {
25+
const port = isServer ? new URL(getRequestEvent()!.request.url).port: location.port;
26+
fetch(`http://localhost:${port}/${import.meta.env.SERVER_BASE_URL}/unknown`, {
2627
headers: { Accept: "application/json" }
2728
}).then(async res => console.log(await res.json()));
2829
return (

0 commit comments

Comments
 (0)