500 Error in dashboard on first load


#1

Internal Server Error (500)

TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
    at new Hmac (internal/crypto/hash.js:89:11)
    at Object.createHmac (crypto.js:125:10)
    at sign (/opt/bitnami/app/lightsail-vapid-test/node_modules/keygrip/index.js:22:8)
    at Keygrip.sign (/opt/bitnami/app/lightsail-vapid-test/node_modules/keygrip/index.js:29:38)
    at Cookies.set (/opt/bitnami/app/lightsail-vapid-test/node_modules/cookies/index.js:109:30)
    at ContextSession.save (/opt/bitnami/app/lightsail-vapid-test/node_modules/koa-session/lib/context.js:321:22)
    at ContextSession.commit (/opt/bitnami/app/lightsail-vapid-test/node_modules/koa-session/lib/context.js:231:16)
    at session (/opt/bitnami/app/lightsail-vapid-test/node_modules/koa-session/index.js:46:20)

Hosted on AWS lightsail using the bitnami nodejs blueprint.

The front-end works fine, but going to the dashboard produces the error above. This feels like a missing dependency or something, but I’m having trouble narrowing it down.


#2

@ryanm It looks like it’s having a hard time finding the SECRET_KEY, used for sessions. Usually, Vapid reads this in from a .env file at root, but in production environments you can just create a ENV variable.

Sounds like you may be a candidate for the latter. Try setting an ENV variable for SECRET_KEY=somethingsecret.


#3

Thank you, that solved it.

Are there any libraries already integrated with vapid for managing ENV variables? Right now I’m setting them on the server-side simply by setting them in the startup script that is managed by the server, which ensures that the site starts properly on boot.

Any easy way to implement something like dotenv would be useful.


#4

@ryanm Glad to hear it worked.

Actually, dotenv is already built in, so if you place a .env file in the site’s root, it should pick it up.