Why does react app has two local storages?

I have encountered a weird behavior of my React app. For some reason it has two local storages. One at app IP and another – at app domain. I suspect this is happening because I set the domain to be a subdomain pointing to a specific IP via the URL redirect record in DNS configuration. When I try to set a storage item with localStorage.setItem('item', 'value'), app does not pick it up because (I am figuring this is the case) it uses second storage while browser is using first one by default. Another weird aspect of this is that when app does window.history.pushState(null, 'title', '?name=val'), it has no effect whatsoever, while if I do the same from the browser console, it works fine – URL gets updated. Everything works fine on localhost – there is only one storage and window.history does what it is supposed to.

How can I fix this? Probably some configuration of npm start? I tried setting start: "PORT=80 HOST=subdomain.domain.com react-scripts start" in package.json, but app does not start it this case at all.

Any ideas are welcome. Thanks.

Source: JavaSript – Stack Overflow

November 27, 2021
Category : News
Tags: dns | javascript | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.