【发布时间】:2017-07-26 20:54:55
【问题描述】:
在流星文档 (https://guide.meteor.com/security.html#secret-code) 中的秘密服务器代码部分,他们似乎使用了仅在服务器上定义的全局变量,因此,只能在服务器上查看和访问代码。看起来很简单。
但是当我这样做时
upload = { test: "my secret code" }
在文件夹server/upload.js 内我得到错误
W20170726-10:04:59.843(2)? (STDERR)
C:\Users\myuser\AppData\Local\.meteor\packages\meteor-tool\1.5.0\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
W20170726-10:04:59.844(2)? (STDERR) throw(ex);
W20170726-10:04:59.846(2)? (STDERR) ^
W20170726-10:04:59.847(2)? (STDERR)
W20170726-10:04:59.847(2)? (STDERR) ReferenceError: upload is not defined
W20170726-10:04:59.848(2)? (STDERR) at meteorInstall.server.upload.upload.js (server/upload/upload.js:1:1)
W20170726-10:04:59.849(2)? (STDERR) at fileEvaluate (packages\modules-runtime.js:333:9)
W20170726-10:04:59.850(2)? (STDERR) at require (packages\modules-runtime.js:228:16)
W20170726-10:04:59.851(2)? (STDERR) at C:\Users\myuser\Documents\projects\myproject\.meteor\local\build\programs\server\app\app.js:10417:1
W20170726-10:04:59.852(2)? (STDERR) at C:\Users\myuser\Documents\projects\myproject\.meteor\local\build\programs\server\boot.js:338:34
W20170726-10:04:59.853(2)? (STDERR) at Array.forEach (native)
W20170726-10:04:59.854(2)? (STDERR) at Function._.each._.forEach (C:\Users\myuser\AppData\Local\.meteor\packages\meteor-tool\1.5.0\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20170726-10:04:59.855(2)? (STDERR) at C:\Users\myuser\Documents\projects\myproject\.meteor\local\build\programs\server\boot.js:158:5
W20170726-10:04:59.856(2)? (STDERR) at C:\Users\myuser\Documents\projects\myproject\.meteor\local\build\programs\server\boot.js:387:5
W20170726-10:04:59.858(2)? (STDERR) at Function.run (C:\Users\myuser\Documents\projects\myproject\.meteor\local\build\programs\server\profile.js:510:12)
是文档有误还是我只是在做一些奇怪的事情?我正在使用流星版本 1.5.0,在 windows 和 linux 上都发生了。
【问题讨论】: