UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 930 B
{"version":3,"file":"get-request-base-url.mjs","names":[],"sources":["../../../../src/libs/http/utils/get-request-base-url.ts"],"sourcesContent":["import type { LucidHonoContext } from \"../../../types/hono.js\";\nimport { normalizeHost } from \"../../../utils/helpers/index.js\";\n\n/**\n * Returns the base URL for the Lucid instance from a Hono context.\n * If config.host is set, it will be used.\n * Otherwise, the origin is extracted from the request URL.\n */\nconst getRequestBaseUrl = (c: LucidHonoContext): string => {\n\tconst config = c.get(\"config\");\n\tif (config.host?.trim()) {\n\t\treturn normalizeHost(config.host);\n\t}\n\n\tconst url = new URL(c.req.url);\n\treturn normalizeHost(url.origin);\n};\n\nexport default getRequestBaseUrl;\n"],"mappings":"wEAQA,MAAM,EAAqB,GAAgC,CAC1D,IAAM,EAAS,EAAE,IAAI,QAAQ,EAM7B,OALI,EAAO,MAAM,KAAK,EACd,EAAc,EAAO,IAAI,EAI1B,EAAc,IADL,IAAI,EAAE,IAAI,GACH,CAAC,CAAC,MAAM,CAChC"}