简体   繁体   English

如何将 javascript 文件(其中包含多个函数)从服务器发送到客户端?

[英]How to send a javascript file (with several functions in it) from the server to the client side?

I need to have the functionality in the server side in order to hide the implementetion to the final user.我需要在服务器端拥有该功能,以便向最终用户隐藏实现。 I didn't find a topic with this kind of solution.我没有找到这种解决方案的主题。

I have a .js file with functions I use within the html5 file.我有一个 .js 文件,其中包含我在 html5 文件中使用的函数。 The js files are "called" in the html by using the script tag, but through the url the user can track them and see the .js file content. js 文件通过使用 script 标签在 html 中“调用”,但用户可以通过 url 跟踪它们并查看 .js 文件内容。 I don't want this to happen.我不希望这种情况发生。 $getScript() does the job, but again the url can be cathched, thus the file content too. $getScript() 完成了这项工作,但同样可以捕获 url,因此也可以捕获文件内容。 Much the same with $ajax function.与 $ajax 函数大致相同。 Everything work ok, but I want to hide the js content.一切正常,但我想隐藏 js 内容。

The .js file is something like this: .js 文件是这样的:

var x, x,....

function A(){...}
function B(){...}

and so on, I use A(), B() functions in the html.依此类推,我在 html 中使用 A(), B() 函数。

Which is the best approach to get the content file from the server without doing the url visible?从服务器获取内容文件而不使 url 可见的最佳方法是什么?

Server: nodejs.服务器:nodejs。 (I send some json files through socket.io correctly, but I don't know how to achieve this other issue. (我通过 socket.io 正确发送了一些 json 文件,但我不知道如何实现另一个问题。

Thanks in advance, best!提前致谢,最好!

If you are sending sensitive information to the client then you are doing it wrong.如果您向客户发送敏感信息,那么您就做错了。 No matter if the client has the URL to the script, they will still be able to find it if they are determined as long as it is sent to their computer.无论客户端是否有脚本的 URL,只要确定了,只要发送到他们的计算机,他们仍然可以找到它。

Find a different way to accomplish what you are trying to do without sending sensitive information to the client.找到一种不同的方式来完成您正在尝试做的事情,而无需向客户端发送敏感信息。 It is not safe.它不安全。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不使用处理程序的情况下使用ajax从客户端将文件发送到服务器端? - How to send file to server side from client side using ajax without using handler? 如何从服务器端javascript从不同的域获取.txt文件并获取它的客户端 - How to fetch a .txt file from a different domain from server side javascript and get it client side 如何从客户端 JavaScript 文件中引用云函数中的格式化文件名? - How can I refer formatted file name in cloud functions from client side JavaScript file? 如何在JavaScript客户端和服务器端使用输入文件类型 - How to use input file type in javascript client side and server side 如何使用JQUERY使用AJAX将Javascript变量(从客户端)发布到PHP文件(服务器端) - How to POST a Javascript Variable (From Client Side) to PHP File (Server Side) with AJAX using JQUERY 无法从客户端将文件数据发送到Node.js服务器 - Unable to send file data to nodejs server from client side 将压缩的 PDF 文件内容从客户端发送到后端服务器 - Send compressed PDF file contents from client side to backend server 如何将客户端数据发送到服务器端 - How to send client side data to server side 如何从服务器端nodejs访问客户端javascript变量? - How to accessing client side javascript variable from server side nodejs? 如何从服务器端更改客户端javascript的变量? - How to change client side javascript 's variable from server side?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM