Localstorage Access from Local File

localStorage access from local file

When you are opening the files locally, i.e. using the file:// protocol, as of now the browsers can not determine what is "same domain" so every file is considered a separate domain. Thus you can not use localStorage when you're opening the files.

Here is some more information on the problem in FireFox: https://bugzilla.mozilla.org/show_bug.cgi?id=507361 . Personally I couldn't find much about Safari on this topic.

You can also look over this: Javascript/HTML Storage Options Under File Protocol (file://) . It might be helpful in your situation.

Accessing localStorage from js file cached by ServiceWorker

That's fine, yes.

You can think about the service worker as proxying the network requests that are made for logic.js and any other resources/subresources. Once the network request is done, the service worker is effectively "out of the picture" (the thread that it's running in will actually stop unless there are active events).

The fact that the service worker was involved in loading logic.js does not prevent you from using local storage or doing anything else from within logic.js.

How do I allow my local web page access to LocalStorage in Brave Browser?

There is 2 ways you can achieve this. Probably also depends how you run your project. I use VS Code and when I run my projects in Brave I got that error. My files were just in a dev directory not in the wwwroot directory.

  1. First option (recommended in my opinion)

    • Go to: Setting->Additional Settings->Privacy and Security->Site Settings->Cookies
    • In the "Allow" section add: "localhost" and "127.0.0.1"
      Preferred option
  2. Second option (not recommended, as you also stated you don't want to do this)

    • Go to: Settings->Shields->Cookie Control
    • Select "Allow all cookies"
      Not recommended option

Hope this helps



Related Topics



Leave a reply



Submit