I have a folder structure like this:
pages
- [lang]
- - index.astro
- index.astro
the [lang] > index.astro looks something like this:
---
import Base from "@layouts/Base.astro";
import { getLangFromUrl, useTranslations } from "@i18n/utils";
const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang);
---
<script>
const div = document.querySelector(".test");
if (div) {
div.textContent = document.URL;
}
</script>
<Base>
<main id="main-content">
<div>Javascript (document.URL)</div>
<div class="test"></div>
<br />
<div>Astro.request.url</div>
<div>{Astro.request.url}</div>
<br />
<div>Astro.url</div>
<div>{Astro.url}</div>
</main>
</Base>
The output can be seen on the screenshot.
The root index.astro has the following content:
---
return Astro.redirect("/en");
---
<meta http-equiv="refresh" content="0;url=/en/" />
Basically I just want it to redirect to /en/.