【发布时间】:2021-08-11 15:52:16
【问题描述】:
我有这个带有 firebase 身份验证的 MERN 应用程序运行良好。它使用自定义令牌在后端(node.js)中对用户进行身份验证。
decode id token 正在使用这个语句:
const header = req.headers?.authorization;
但在将其部署到 digitalocean 时会引发以下错误:
/home/admin-nithur/app/authenticateToken.js:8
const header = req.headers?.authorization;
^
SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/admin-nithur/app/server.js:9:23)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
为什么会这样?有什么想法吗?
【问题讨论】:
标签: javascript node.js firebase-authentication digital-ocean