Skip to content

[Bug]: locales no longer working #1897

Closed
@EmmaDawsonDev

Description

@EmmaDawsonDev

Summary

I work for a Nordic Company and we currently have our website on netlify composed of 2 next apps and it uses domain-based locales for Sweden, Norway, Finland and Denmark. website.se is the default, and website.no, website.fi and website.dk are all set up to show the locale-specific version of the site. These all route to the second next app when a user clicks a "Book Now" button where website.se/booking is the default and website.no/booking, website.fi/booking and website.dk/booking are the locales.

Everything was working fine. However, when we made a production release last week the next plugin for netlify updated to 4.30.0 from 4.29.4. This caused all our locales to default to the .se/booking site when a user clicked the "Book Now" button even though the url was still showing the correct domain locale and this prevented customers in Norway, Finland and Denmark from being able to make bookings.

We've currently rolled back to 4.29.4 but it would be good to know what the issue is that caused this, if there's some extra config needed on our end (everything is set up according to the nextJS i18n documentation) and not have to worry that updates to this plugin will cause issues for us in the future.

Steps to reproduce

This happened when we made a production release last week and the plugin updated to 4.30.0.

A link to a reproduction repository

No response

Next Runtime version

4.30.0

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

None

Your netlify.toml file

`netlify.toml`
[[plugins]]
  package = "@netlify/plugin-nextjs"

[[plugins]]
  package = "./plugins/netlify/stop-build"

[[plugins]]
  package = "./plugins/netlify/copy-public-files"

# Pausing this until we have a solid suite of e2e tests
# [[context.production.plugins]]
#   package = "./plugins/netlify/run-cypress"

[context.deploy-preview.environment]
  NEXT_PUBLIC_RELESE_STAGE = "deploy-preview"

[build.environment]
  NODE_VERSION = "14"

Your public/_redirects file

`_redirects`
Redirects for the main app
#######################
# domain setup for hosts
#######################
http://website.se/* https://www.website.se/:splat 301!
http://website.fi/* https://www.website.fi/:splat 301!
http://website.dk/* https://www.website.dk/:splat 301!
http://website.no/* https://www.website.no/:splat 301!

https://website.se/* https://www.website.se/:splat 301!
https://website.fi/* https://www.website.fi/:splat 301!
https://website.dk/* https://www.website.dk/:splat 301!
https://website.no/* https://www.website.no/:splat 301!

http://www.website.se/* https://www.website.se/:splat 301!
http://www.website.fi/* https://www.website.fi/:splat 301!
http://www.website.dk/* https://www.website.dk/:splat 301!
http://www.website.no/* https://www.website.no/:splat 301!


###########################
# Prevent localised domains from accessing other unsuported locales through subpath
###########################
https://www.website.dk/fi/* https://www.website.dk/:splat 301!
https://www.website.dk/sv-FI/* https://www.website.dk/:splat 301!
https://www.website.dk/nb/* https://www.website.dk/:splat 301!
https://www.website.dk/sv/* https://www.website.dk/:splat 301!

https://www.website.fi/da/* https://www.website.fi/:splat 301!
https://www.website.fi/nb/* https://www.website.fi/:splat 301!
https://www.website.fi/sv/* https://www.website.fi/:splat 301!

https://www.website.no/da/* https://www.website.no/:splat 301!
https://www.website.no/fi/* https://www.website.no/:splat 301!
https://www.website.no/sv-FI/* https://www.website.no/:splat 301!
https://www.website.no/sv/* https://www.website.no/:splat 301!

https://www.website.se/da/* https://www.website.se/:splat 301!
https://www.website.se/fi/* https://www.website.se/:splat 301!
https://www.website.se/sv-FI/* https://www.website.se/:splat 301!
https://www.website.se/nb/* https://www.website.se/:splat 301!

https://staging.website.dk/fi/* https://staging.website.dk/:splat 301!
https://staging.website.dk/sv-FI/* https://staging.website.dk/:splat 301!
https://staging.website.dk/nb/* https://staging.website.dk/:splat 301!
https://staging.website.dk/sv/* https://staging.website.dk/:splat 301!

https://staging.website.fi/da/* https://staging.website.fi/:splat 301!
https://staging.website.fi/nb/* https://staging.website.fi/:splat 301!
https://staging.website.fi/sv/* https://staging.website.fi/:splat 301!

https://staging.website.no/da/* https://staging.website.no/:splat 301!
https://staging.website.no/fi/* https://staging.website.no/:splat 301!
https://staging.website.no/sv-FI/* https://staging.website.no/:splat 301!
https://staging.website.no/sv/* https://staging.website.no/:splat 301!

https://staging.website.se/da/* https://staging.website.se/:splat 301!
https://staging.website.se/fi/* https://staging.website.se/:splat 301!
https://staging.website.se/sv-FI/* https://staging.website.se/:splat 301!
https://staging.website.se/nb/* https://staging.website.se/:splat 301!

###########################
# Redirects for locale paths
###########################
https://www.website.se/sv/* https://www.website.se/:splat 301!
https://www.website.dk/da/* https://www.website.dk/:splat 301!
https://www.website.no/nb/* https://www.website.no/:splat 301!
https://www.website.fi/fi/* https://www.website.fi/:splat 301!
https://staging.website.se/sv/* https://staging.website.se/:splat 301!
https://staging.website.dk/da/* https://staging.website.dk/:splat 301!
https://staging.website.no/nb/* https://staging.website.no/:splat 301!
https://staging.website.fi/fi/* https://staging.website.fi/:splat 301!

#####################
# Proxy to Booking app
#####################
https://www.website.se/booking partnerId=:partnerId https://www.website.se/booking/:partnerId 301!
https://www.website.dk/booking partnerId=:partnerId https://www.website.dk/booking/:partnerId 301!
https://www.website.no/booking partnerId=:partnerId https://www.website.no/booking/:partnerId 301!
https://www.website.fi/booking partnerId=:partnerId https://www.website.fi/booking/:partnerId 301!
https://www.website.fi/booking/sv-FI partnerId=:partnerId https://www.website.fi/booking/sv-FI/:partnerId 301!

https://staging.website.se/booking partnerId=:partnerId https://staging.website.se/booking/:partnerId 301!
https://staging.website.dk/booking partnerId=:partnerId https://staging.website.dk/booking/:partnerId 301!
https://staging.website.no/booking partnerId=:partnerId https://staging.website.no/booking/:partnerId 301!
https://staging.website.fi/booking partnerId=:partnerId https://staging.website.fi/booking/:partnerId 301!
https://staging.website.fi/booking/sv-FI partnerId=:partnerId https://staging.website.fi/booking/sv-FI/:partnerId 301!

https://www.website.dk/booking/* https://booking.website.dk/booking/:splat 200!
https://www.website.fi/booking/* https://booking.website.fi/booking/:splat 200!
https://www.website.no/booking/* https://booking.website.no/booking/:splat 200!
https://www.website.se/booking/* https://booking.website.se/booking/:splat 200!

https://staging.website.dk/booking/* https://staging.booking.website.dk/booking/:splat 200!
https://staging.website.fi/booking/* https://staging.booking.website.fi/booking/:splat 200!
https://staging.website.no/booking/* https://staging.booking.website.no/booking/:splat 200!
https://staging.website.se/booking/* https://staging.booking.website.se/booking/:splat 200!


##############################
# Content preview rewrites
# Needs to come before legacy /api/ handler
##############################
/api/preview /.netlify/functions/___netlify-handler 200!
/api/exit-preview /.netlify/functions/___netlify-handler 200!


##############################
# Serve correct SSG landing page
##############################
# Make landing page work in preview mode
https://staging.website.dk/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://staging.website.fi/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://staging.website.fi/sv-FI /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://staging.website.no/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://staging.website.se/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data

https://www.website.dk/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://www.website.fi/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://www.website.fi/sv-FI /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://www.website.no/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data
https://www.website.se/ /.netlify/functions/___netlify-handler 200! Cookie=__prerender_bypass,__next_preview_data

https://staging.website.dk/ https://staging.website.dk/da.html 200!
https://staging.website.fi/ https://staging.website.fi/fi.html 200!
https://staging.website.fi/sv-FI https://staging.website.fi/sv-FI.html 200!
https://staging.website.no/ https://staging.website.no/nb.html 200!
https://staging.website.se/ https://staging.website.se/sv.html 200!

https://www.website.dk/ https://www.website.dk/da.html 200!
https://www.website.fi/ https://www.website.fi/fi.html 200!
https://www.website.fi/sv-FI https://www.website.fi/sv-FI.html 200!
https://www.website.no/ https://www.website.no/nb.html 200!
https://www.website.se/ https://www.website.se/sv.html 200!



Redirects for /booking app
#######################
# basePath redirect
#######################
/ /booking  301!

##############################
# Content preview rewrites to turn on preview mode
##############################
/booking/api/preview /.netlify/functions/___netlify-handler 200!
/booking/api/exit-preview /.netlify/functions/___netlify-handler 200!


##############################
# Serve correct SSG page and not use netlify function to render
##############################
https://booking.website.dk/booking https://booking.website.dk/booking/da.html 200!
https://booking.website.fi/booking https://booking.website.fi/booking/fi.html 200!
https://booking.website.fi/booking/sv-FI https://booking.website.fi/booking/sv-FI.html 200!
https://booking.website.no/booking https://booking.website.no/booking/nb.html 200!
https://booking.website.se/booking https://booking.website.se/booking/sv.html 200!

https://staging.booking.website.dk/booking https://staging.booking.website.dk/booking/da.html 200!
https://staging.booking.website.fi/booking https://staging.booking.website.fi/booking/fi.html 200!
https://staging.booking.website.fi/booking/sv-FI https://staging.booking.website.fi/booking/sv-FI.html 200!
https://staging.booking.website.no/booking https://staging.booking.website.no/booking/nb.html 200!
https://staging.booking.website.se/booking https://staging.booking.website.se/booking/sv.html 200!

##############################
# Rewrite partner params to its unique page
##############################
https://booking.website.se/booking/:partnerId https://booking.website.se/booking/sv/:partnerId 200
https://booking.website.dk/booking/:partnerId https://booking.website.dk/booking/da/:partnerId 200
https://booking.website.no/booking/:partnerId https://booking.website.no/booking/nb/:partnerId 200
https://booking.website.fi/booking/:partnerId https://booking.website.fi/booking/fi/:partnerId 200

https://staging.booking.website.se/booking/:partnerId https://staging.booking.website.se/booking/sv/:partnerId 200
https://staging.booking.website.dk/booking/:partnerId https://staging.booking.website.dk/booking/da/:partnerId 200
https://staging.booking.website.no/booking/:partnerId https://staging.booking.website.no/booking/nb/:partnerId 200
https://staging.booking.website.fi/booking/:partnerId https://staging.booking.website.fi/booking/fi/:partnerId 200

Your next.config.js file

`next.config.js`
Home page config:
const developmentEnvs = ['staging', 'development'];
const isDev = developmentEnvs.includes(process.env.NODE_ENV);
const withNx = require('@nrwl/next/plugins/with-nx');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
  openAnalyzer: false,
});

module.exports = withNx(
  withBundleAnalyzer({
    nx: {
      // Set this to false if you do not want to use SVGR
      // See: https://github.com/gregberge/svgr
      svgr: true,
    },
    images: {
      domains: ['images.ctfassets.net'],
    },
    i18n: {
      locales: ['da', 'fi', 'nb', 'sv', 'sv-FI'],
      defaultLocale: 'sv',
      localeDetection: false,
      domains: isDev
  ? [
      {
        domain: 'staging.website.se',
        defaultLocale: 'sv',
      },
      {
        domain: 'staging.website.no',
        defaultLocale: 'nb',
      },
      {
        domain: 'staging.website.dk',
        defaultLocale: 'da',
      },
      {
        domain: 'staging.website.fi',
        defaultLocale: 'fi',
        locales: ['sv-FI'],
      },
    ]
  : [
      {
        domain: 'www.website.se',
        defaultLocale: 'sv',
      },
      {
        domain: 'www.website.no',
        defaultLocale: 'nb',
      },
      {
        domain: 'www.website.dk',
        defaultLocale: 'da',
      },
      {
        domain: 'www.website.fi',
        defaultLocale: 'fi',
        locales: ['sv-FI'],
      },
    ];
    },
    
    },
  })
);

/booking config
const withNx = require('@nrwl/next/plugins/with-nx');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
  openAnalyzer: false,
});

module.exports = withNx(
  withBundleAnalyzer({
    basePath: '/booking',
    nx: {
      // Set this to false if you do not want to use SVGR
      // See: https://github.com/gregberge/svgr
      svgr: true,
    },
    images: {
      domains: ['images.ctfassets.net'],
    },
    i18n: {
      locales: ['da', 'fi', 'nb', 'sv', 'sv-FI'],
      defaultLocale: 'sv',
      localeDetection: false,
      // This is a list of locale domains and the default locale they
      // should handle (these are only required when setting up domain routing)
      // Note: subdomains must be included in the domain value to be matched e.g. "fr.example.com".
      domains: [
        {
          domain: 'staging.booking.website.se',
          defaultLocale: 'sv',
        },
        {
          domain: 'staging.booking.website.no',
          defaultLocale: 'nb',
        },
        {
          domain: 'staging.booking.website.dk',
          defaultLocale: 'da',
        },
        {
          domain: 'staging.booking.website.fi',
          defaultLocale: 'fi',
        },
      ],
    },
  })
);

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions