Skip to content

import.meta.env.BASE_URL ends in a trailing slash when trailingSlash is never if base is unset #15440

@eblocha

Description

@eblocha

Astro Info

Astro                    v5.17.1
Vite                     v6.4.1
Node                     v24.13.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When base is unset, and trailingSlash is never, the import.meta.env.BASE_URL is /, which makes it awkward to use to construct urls to other pages. It means I cannot depend on the setting of trailingSlash when creating a url relative to the base, and need to always check if there is a trailing slash anyways.

What's the expected result?

import.meta.env.BASE_URL should be an empty string if trailingSlash is never and base is unset, an empty string, or /.

Link to Minimal Reproducible Example

https://github.com/eblocha/astro-base-tralingslash

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions