Skip to content

Possibility for Basic Auth #20355

@boazpoolman

Description

@boazpoolman

Bug report

Required System information

  • Node.js version: v18.18.2
  • NPM version: 9.8.1
  • Strapi version: 4.19.0
  • Database: Postgres
  • Operating system: Mac
  • Is your project Javascript or Typescript: Typescript

Describe the bug

I'm trying to add Basic Auth (https://en.wikipedia.org/wiki/Basic_access_authentication) to my Strapi application, but I'm met with the following issue when I do so: https://forum.strapi.io/t/infinite-redirect-loop-first-admin/38299/2

Steps to reproduce the behavior

  1. Deploy Strapi
  2. Add Basic Auth to the domain

Expected behavior

I would expect this to work, but instead I'm getting the error as described in the forum post.

Code snippets

The problem is with the fetchClient. In there the Authorization header is set to Bearer ${auth.getToken()}. Because that header doesn't include the Basic auth this problem occurs.

Proposed solution

We could probably include both Basic auth AND Bearer token in the Authorization header.
If you guys agree with this solution I could write up a PR.

Additional context

I've tried setting the url in the config/server.js to include the Basic auth in the URL like so: http://username:password@127.0.0.1:1337 but that didn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions