Skip to content

Conversation

@fujikky
Copy link
Contributor

@fujikky fujikky commented Aug 8, 2019

I found the issue that redirect and changeLocale function are wrong when using gatsby's prefix path (like /intl).

redirect:

  • Expected: /intl/ -> /intl/en/
  • Actual: /intl/ -> /intl/en/intl/

changeLocale function (en -> de):

  • Expected: /intl/en/ -> /intl/de/
  • Actual: /intl/en/ -> /intl/de/en/

You can reproduce this problem with gatsby-starter-default-intl using this patch.

diff --git a/examples/gatsby-starter-default-intl/gatsby-config.js b/examples/gatsby-starter-default-intl/gatsby-config.js
index 24c6a80..165d2f7 100644
--- a/examples/gatsby-starter-default-intl/gatsby-config.js
+++ b/examples/gatsby-starter-default-intl/gatsby-config.js
@@ -1,4 +1,5 @@
 module.exports = {
+  pathPrefix: `/intl`,
   siteMetadata: {
     title: `Gatsby Default Starter`,
     description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
diff --git a/examples/gatsby-starter-default-intl/package.json b/examples/gatsby-starter-default-intl/package.json
index 403542a..88d9615 100644
--- a/examples/gatsby-starter-default-intl/package.json
+++ b/examples/gatsby-starter-default-intl/package.json
@@ -27,11 +27,11 @@
   ],
   "license": "MIT",
   "scripts": {
-    "build": "gatsby build",
+    "build": "gatsby build --prefix-paths",
     "develop": "gatsby develop",
     "format": "prettier --write src/**/*.{js,jsx}",
     "start": "npm run develop",
-    "serve": "gatsby serve",
+    "serve": "gatsby serve --prefix-paths",
     "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\""
   },
   "repository": {

and run: $ yarn build && yarn serve && open http://localhost:9000/intl/

@wiziple wiziple changed the base branch from master to versions/0.2.8 August 9, 2019 23:36
@wiziple wiziple merged commit 73326cd into wiziple:versions/0.2.8 Aug 9, 2019
@alfonmga
Copy link

alfonmga commented Oct 22, 2019

I'm using redirect: false gatsby-plugin-intl config option and when I use changeLocale function to switch to default language it adds /en URL prefix.

Is this a bug? I don't would like to use a prefix URL path for the default language.
Also I think /en URL path aka default language should throw out an 404 error in this scenario, it would make sense to avoid duplicate content.

This is the repo btw: https://github.com/voicerum/homepage/tree/c76c80a7c1efe5a35ba3043fd338d3aa09feacd5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants