Search code examples
javascriptherokunpmclient-serverlite-server

Client side code updating server side code


I have deployed a simple javascript memory game to heroku with lite-server. https://happy-birthday-eline.herokuapp.com

To my surprise, when a user turns a card, all other users see the card turn too. I can't figure out why. I thought client-side actions were limited to the client and could in no way update the server or impact other users. How do I prevent a user action (click on card) from propagating to all other users? Thanks

Answer: I thought I could just deploy using lite-server (rather than express) but lite-server has file listening enabled, which is why user actions were impacting all other users. (Obvious) solution was to use express on Heroku, not lite-server!


Solution

  • It's caused by BrowserSync. Looks like you deployed a development version of your code and BrowserSync is connected.

    In order to avoid it, you have to deploy a production version of your application.