Search code examples
gun

How to make sure client doesn't sync when switching from dev to live server


When I change the url in the client from localhost to myLiveServer.com, how do I make sure that the localStorage doesn't get synced with the live data? Do I need to configure that somewhere and extend the url like... localhost:8080/gun/dev and myLiveServer.com/gun/live


Solution

  • Yes, it is probably wise to do something like this:

    var gun = Gun('http://localhost:8080/gun').get('development');
    

    And then in production, do something like:

    var gun = Gun('http://myserver.com/gun').get('uniqueAppName');
    

    Great question though, maybe this is something we can improve/make easier in the future.

    Let me know if this works.