Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Can the code in the server of Node.js be accessed by the client?

Tags: server code rule

Can the code in the server of Node.js be accessed by the client?

Problem

I want to develop a game in NodeJS but i'm not sure how much 'easily' hackable it is. For example if i write my game rules in PHP modifing them will need the hacker to actually get access to the Server, instead if my rules where in javascript anyone could easily rewrite the rules as they want.

More over if the game would involve people discovering rules as they play how could i prevent those rules to be there for anyone just by looking at the Code.

Problem courtesy of: EH_warch

Solution

The actual code of your Node.js app will remain unexposed. Ideally, your client (whatever you're doing on the browser side of things, whether this is rendering html elements or using html5 canvas) will only handle I/O and update your server, while your server will take care of all logic.

You can still use javascript client side, but keep in mind that your fear is legitimate concerning client side javascript. This is why it is common practice to separate input/output code (which happens in javascript on the client) from game logic code that happens on the server. So the worst thing someone would be able to do is to send a message to your server saying they are pressing every key at once, and you can filter for things like this.

Solution courtesy of: swiecki

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Can the code in the server of Node.js be accessed by the client?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×