Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.crypto.subtle is undefined when connecting to http://localhost:3000 on firefox

I wanted to start working again on a Single Page Application I was building a few months ago.

It integrates with Azure Cloud and uses its libraries to login.

The deployed instance works using https and it behaves correctly on any browser, the local instance I use for development instead only works on google chrome, not on firefox.

While reading the output console I see:

BrowserAuthError: pkce_not_created: The PKCE code challenge and verifier could not be generated. Detail:TypeError: window.crypto.subtle is undefined

I've checked that the code is the same running on the deployed instance, plus the local version works on google chrome. I get this error while loading the page using http://localhost:3000 only on firefox.

All this makes me assume that a recent update of firefox decided to block window.crypto.subtle if not using HTTPS, even if connecting to localhost. Do you think this is the issue? Do you know how can I roll back to the previous settings that allowed me to test it locally as well?

like image 564
LLL Avatar asked Aug 31 '25 01:08

LLL


1 Answers

The answer is at the beginning of a SubtleCrypto documentation:

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Thats the reason why window.crypto.subtle it's undefined.

If you want test it locally, you could generate HTTPS certificates locally or use tool like NGROK to expose your http server as https using 1 command instead of trying to rollback to some kind of old version of the browser.

like image 94
ulou Avatar answered Sep 03 '25 18:09

ulou