From fb745ef749d851031c494f602ff8611a6b1dab14 Mon Sep 17 00:00:00 2001 From: Aaron Harper Date: Mon, 9 Dec 2024 11:54:57 -0500 Subject: [PATCH] Fix Nuxt and H3 use https when no NODE_ENV (#773) ## Summary Fix the SDK reporting its scheme as `https` when the `NODE_ENV` env var isn't set. --- .changeset/angry-houses-move.md | 5 +++++ packages/inngest/src/h3.ts | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .changeset/angry-houses-move.md diff --git a/.changeset/angry-houses-move.md b/.changeset/angry-houses-move.md new file mode 100644 index 000000000..cbf1ad9c2 --- /dev/null +++ b/.changeset/angry-houses-move.md @@ -0,0 +1,5 @@ +--- +"inngest": patch +--- + +Fix Nuxt and H3 uses https in dev diff --git a/packages/inngest/src/h3.ts b/packages/inngest/src/h3.ts index 59833bb46..e95fdc31a 100644 --- a/packages/inngest/src/h3.ts +++ b/packages/inngest/src/h3.ts @@ -89,13 +89,17 @@ export const serve = ( body: () => readBody(event), headers: (key) => getHeader(event, key), method: () => event.method, - url: () => - new URL( + url: () => { + let scheme = "https"; + if ((processEnv("NODE_ENV") ?? "dev").startsWith("dev")) { + scheme = "http"; + } + + return new URL( String(event.path), - `${ - processEnv("NODE_ENV") === "development" ? "http" : "https" - }://${String(getHeader(event, "host"))}` - ), + `${scheme}://${String(getHeader(event, "host"))}` + ); + }, queryString: (key) => { const param = getQuery(event)[key]; if (param) {