Basic auth failing with "Unsupported Authorization Type"

Using latest XDN 2.20.2, I have implemented basic auth in my router:

module.exports = new Router()
  .requireBasicAuth({
    username: process.env.BASIC_AUTH_USERNAME,
    password: process.env.BASIC_AUTH_PASSWORD,
  })
  .match('/service-worker.js', ({ serviceWorker }) => {
    return serviceWorker('.next/static/service-worker.js')
  })
  .use(nextRoutes) // automatically adds routes for all files under /pages

Locally, I am prompted for credentials when visiting the site. Authorization is successful.

When deployed, I am also prompted, but I get a 400 Invalid Argument response:

<Error>
<Code>InvalidArgument</Code>
<Message>Unsupported Authorization Type</Message>
<ArgumentName>Authorization</ArgumentName>
<ArgumentValue>Basic XXX</ArgumentValue>
<RequestId>81A26BF1B8F832C4</RequestId>
<HostId>btQlD9wdBpX6GX0sW5z6Tld6sbPIJRbyWvuGckWWSj09juj2dhunSItPcsorfyBF2yIaHUNelws=</HostId>
</Error>

When I enter incorrect credentials, I get an expected 403, but with correct credentials I see this 400 error. Is this an issue with my implementation?

Thank you for reporting this - we are looking into it.

We have isolated the issue and will be releasing a patch as soon as possible.

We have released v2.20.3 which fixes this issue. Could you test it and confirm?

Looks like the issue is fixed in 2.20.3. Thanks!

1 Like