nextjs-basic-auth-middleware
nextjs-basic-auth-middleware copied to clipboard
Authentication bypassed if the site is internationalised
Hi,
I've been testing your middleware and I realised that if you define some locales inside next.config.js, then the authentication is automatically bypassed. If the user clicks “Cancel” multiple times, they may even see the page's HTML as reported in https://github.com/labd/nextjs-basic-auth-middleware/issues/27 before 2.0.0.
Reproduction steps:
- Clone the repository:
git clone [email protected]:labd/nextjs-basic-auth-middleware.git - Navigate to
nextjs-basic-auth-middleware/examples - Install the dependencies:
yarn - Add some locales to
next.config.js:
/** @type {import('next').NextConfig} */
const nextConfig = {
i18n: {
locales: ['en', 'es'],
defaultLocale: 'en',
},
reactStrictMode: true,
swcMinify: true,
}
module.exports = nextConfig
- Run the development server:
yarn dev - Open the page: http://localhost:3000/
Even before clicking on “Cancel”, inside the “Network” developer panel, you will see that the page's HTML is returned to the browser.