Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirection Bug, with IsPreview (when using locales) #12882

Open
1 task
dreamstar-enterprises opened this issue Jan 2, 2025 · 3 comments
Open
1 task

Redirection Bug, with IsPreview (when using locales) #12882

dreamstar-enterprises opened this issue Jan 2, 2025 · 3 comments
Labels
needs repro Issue needs a reproduction

Comments

@dreamstar-enterprises
Copy link

dreamstar-enterprises commented Jan 2, 2025

Astro Info

5.11

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

No response

Describe the Bug

Hi have these settings:

  base: "/astro",
  site:
    isDev || isPreview
      ? "http://localhost:4321" // development
      : "https://www.myapp.com", // production build

In Dev mode, when I type http://localhost:4321/astro, I get redirected to:http://localhost:4321/astro/en-GB, so ok

In Preview mode, when I type http://localhost:4321/astro, I get redirected to:http://www.myapp.com/astro/en-GB

What's the expected result?

Becase of the logic I have:

In Preview mode, when I type http://localhost:4321/astro, I should get redirected to:http://localhost:4321/astro/en-GB
Or is preview mode using the settings, as if it was in Build?

P.S. I've had to resort to using preview / build mode locally, as astro doesn't yet support accessing astro locally behind a reverse proxy, e.g. http://localhost:7080/astro -> http://localhost:4321/astro

This had been raised as a previous GitHub issue, but was closed, without feature followup.

Link to Minimal Reproducible Example

seeabove

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 2, 2025
@florian-lefebvre florian-lefebvre added the needs repro Issue needs a reproduction label Jan 3, 2025
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Hello @dreamstar-enterprises. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jan 3, 2025
@dreamstar-enterprises
Copy link
Author

This is all you will need to reproduce the issue:

export default defineConfig({
  output: "static",
   base: "/astro",
  site:
    isDev || isPreview
      ? "http://localhost:4321" // development
      : "https://www.myapp.com", // production build
  prefetch: {
    defaultStrategy: "tap",
    prefetchAll: false,
  },
  i18n: {
    defaultLocale: i18nConfig.defaultLocale,
    locales: i18nConfig.locales.map((locale) => locale.code),
    fallback: {
      // @ts-ignore
      "en-us": "en-gb",
    },
    routing: {
      prefixDefaultLocale: true,
      redirectToDefaultLocale: true,
      fallbackType: "rewrite",
    },
  }
}
// Shared i18n configuration
export const i18nConfig = {
  defaultLocale: "en-gb",
  locales: [
    {
      code: "en-gb",
      name: "English (United Kingdom)",
    },
    {
      code: "en-us",
      name: "English (United States)",
    },
  ],
};

// Convert locales array to Record for sitemap (see below)
const sitemapLocales = Object.fromEntries(
  i18nConfig.locales.map((locale) => [locale.code, locale.code]),
);

@florian-lefebvre
Copy link
Member

Can you create a minimal reproduction on stackblitz or as a repo? We can't take the time to manually reproduce unfortunately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue needs a reproduction
Projects
None yet
Development

No branches or pull requests

2 participants