node.js-如何避免下载server.js文件 [英] node.js - how do i avoid server.js file being downloaded

查看:37
本文介绍了node.js-如何避免下载server.js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究MVC4应用程序.这是我的目录结构的样子:

I am working on MVC4 application. This is how my directory structure looks like:

App_Data
App_Start
Content
Controllers
Images
Models
node_modules
Scripts
Views
server.js //This is where my server script resides
Node.exe

这就是它们的整体组合方式:

This is how it all fits together:

Server.js在服务器上运行.用户转到index.cshtml页面并创建到服务器的连接.如果同一页面上有多个用户,他们都可以使用种类"聊天共享数据/想法等.每个用户的操作都会中继到其他已连接的用户.

Server.js is running on a server. User goes to a index.cshtml page and a connection to the server is created. If there are multiple users on the same page, they all can share data/thoughts etc. using "kind of" chat. each user's action is relayed to other connected users.

我想知道的是如何避免有人从浏览器直接指向我的server.js文件并查看其内容.

What i am wondering is how do i avoid someone directly pointing to my server.js file from the browser and view the content of it.

推荐答案

您似乎正在运行两个单独的Web服务器.

You appear to be running two separate web servers.

第一个为您的MVC4 ASP文件提供服务,第二个为您的node.js应用程序提供服务.

The first serves your MVC4 ASP files while the second serves your node.js application.

将node.js文件放在ASP应用程序的Web根下,使访问ASP应用程序的浏览器可以看到它们.

Placing the node.js files under the webroot of your ASP application makes them visible to browsers that visit your ASP application.

node.js本身就是一台Web服务器,不需要任何其他Web服务器即可运行.

node.js is a web server in it's own right and does not require any other web server to operate.

我会将您的node.js应用程序移到ASP Webroot之外.这将使其浏览器无法访问其文件.

I would move your node.js application outside of your ASP webroot. This will make its files inaccessible to browsers.

这篇关于node.js-如何避免下载server.js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆