You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In astro.config.mjs, the value specified in defineConfig is forced to be inserted with a trailing slash. The reason for this is that the transform of zod is used in core/config/schema.ts.
This state is not intended by the user, so that ogp, for example, requires an absolute path to be specified, so it is written as ${import.meta.env.SITE}/ogp.png, but the actual built HTML will contain https://example.com//ogp.png is written in the actual built HTML. Browsers will interpret this URL as convenient, but it may conflict with various other implementations.
After listening to the intent, the transform implementation of zod should be removed if it is not needed, and the URL should be left as specified by the user. If this is necessary, the docs should describe this behavior.
However, if you change it, you have to think about how to do it, or it will cause a bug if you simply stop using the trailing slash.
I don't think that was intentional. We don't use your site config for anything other than setting Astro.site, so you should be free to put any valid URL and we should not touch it. Will accept a PR.
What version of
astro
are you using?1.6.15
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
In astro.config.mjs, the value specified in defineConfig is forced to be inserted with a trailing slash. The reason for this is that the transform of zod is used in
core/config/schema.ts
.astro/packages/astro/src/core/config/schema.ts
Lines 72 to 76 in d7da099
This state is not intended by the user, so that ogp, for example, requires an absolute path to be specified, so it is written as
${import.meta.env.SITE}/ogp.png
, but the actual built HTML will containhttps://example.com//ogp.png
is written in the actual built HTML. Browsers will interpret this URL as convenient, but it may conflict with various other implementations.After listening to the intent, the
transform
implementation of zod should be removed if it is not needed, and the URL should be left as specified by the user. If this is necessary, the docs should describe this behavior.However, if you change it, you have to think about how to do it, or it will cause a bug if you simply stop using the trailing slash.
Link to Minimal Reproducible Example
https://github.com/konojunya/astro-import-meta-env-site
Participation
The text was updated successfully, but these errors were encountered: