Skip to content

Using UpUp with an .htaccess authentification #138

@LrntL

Description

@LrntL

Hi,

My current website is still under development. So I use an .htaccess authentication to restrict the access. Unfortunately, UpUp doesn't handle .htaccess authentication and accessing the site provide an 401 error.

After some reseach, some people (not using UpUp but hand made service worker) resolve this by using {'credentials': 'same-origin'} in fetch(), add() or addAll() methods. (See https://stackoverflow.com/a/47492920)

I change line 62 in upup.sw.js from :
return new Request(urlToPrefetch, { mode: 'no-cors' });

to:
return new Request(urlToPrefetch, { mode: 'no-cors', credentials: 'same-origin' });

And after clearing the cache, it seems to work.
If this is the correct way to make UpUp working with .htaccess authentication, maybe this option could be added in the code.

Let me know if this sounds interesting
Cheers.
Laurent.

  • Version used: 1.1.0
  • Browser Name and version: Chrome Version 75.0.3770.80 (Build officiel) (64 bits)
  • Operating System and version (desktop or mobile): Windows 10 Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions