Skip to content

Testing Domain Internationalization on localhost #12385

@jamieconnor-pv

Description

@jamieconnor-pv

Astro Info

Astro                    v4.16.9
Node                     v18.20.4
System                   macOS (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             none

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

No response

Describe the Bug

I'm trying to test Astro Internationalization using domains on localhost and I am not able to get it display different pages dependant on the domain. It keeps displaying the default template.

I am testing on my local machine. I have set up my host file with so that I can test different domains

127.0.0.1 test
127.0.0.1 zh.test

My astro configuration looks like this
`
import node from '@astrojs/node';
import { defineConfig } from "astro/config";

export default defineConfig({
site: "http://test",
output: "server", // required, with no prerendered pages
adapter: node({
mode: 'standalone',
}),
i18n: {
defaultLocale: "en",
locales: ["en", "zh"],
routing: {
prefixDefaultLocale: false
},
domains: {
zh: "http://zh.test",
}
}
})
`

My pages look like this

pages/en/index.astro
pages/zh/index.astro
pages/index.astro

What's the expected result?

When I go to
zh.test:4321 I expect to get the template inside of src/pages/zh/index.astro
test:4321 I expect to get the template inside of src/pages/en/index.astro (the defaultLocale)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-uryli9

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: i18nRelated to internalization (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions