There is an application running on express. I need to make an API request (to a different port) to get data and write to localStorage, what is the best way to do this, what are the best practices?

    1 answer 1

    The server does not have direct access to the write / read localStorage, you can work with it only from the client part of the application working directly in the browser.

    Unlike cookies, the storage limit is not larger than at least 5MB.

    Transfer:

    Unlike Cookies, [for localStorage] the data limit is higher (at least 5 MB), and information can never be transferred to the server [meaning directly, initiated by the server].

    A source

    As a result, you can only record information from an express-application in a cookie, and only then save it in localStorage by reading from there. Or send an Ajax request from the client side, and after receiving the answer, save it in localStorage.

    • In principle, you can open access to the database from Express, but somehow it bothers me. Is this normal? - Pavel
    • Maybe you should screw Redis? - Pavel