Logged errors and timeouts

Hi there, I am trying to use glitch for the first time and keep running into issues and I am out of ideas. The websites keeps timing out after 10 seconds.

Logs:

MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
at NativeConnection.createClient (/rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:206:11)
at NativeConnection.openUri (/rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/mongoose/lib/connection.js:801:34)
at Mongoose.connect (/rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/mongoose/lib/mongoose.js:404:15)
Jump Toat main (/app/app.js:44:18)
Jump Toat Object.<anonymous> (/app/app.js:42:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)

This is my connection:
const mongoDB = process.env.MONGODB_URI;

main().catch((err) => console.log(err));
async function main() {
await mongoose.connect(mongoDB);

I also get this error:

ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.
at Object.xForwardedForHeader (/rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/express-rate-limit/dist/index.cjs:166:13)
at Object.wrappedValidations.<computed> [as xForwardedForHeader] (/rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/express-rate-limit/dist/index.cjs:338:22)
at Object.keyGenerator (/rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/express-rate-limit/dist/index.cjs:593:20)
at /rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/express-rate-limit/dist/index.cjs:644:32
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /rbd/pnpm-volume/7c3c2d0f-0b1e-4db6-aad4-d27c281813e5/node_modules/express-rate-limit/dist/index.cjs:625:5 {
code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',
help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'

If I set trust proxy to true, it comes with another error saying that anyone can bypass it.

Any help appreciated!

uri parameter thing: something’s wrong with getting the url from your .env to the process. yet there it is in the screenshot, unless there’s some typo that I didn’t notice. maybe that error message was from a previous run?

trust proxy thing: the doc they link to recommends setting it to a number instead of true. what’s the right number for glitch? maybe 1 ish? see their doc on how to test it out by looking at the x-forwarded-for header in a request.

Thanks for input.

I saved value of the variable as a string, so inside quotes, and it works
SnĂ­mka obrazovky 2024-03-19 224338

Is it expected to use the qutoes there like this?

I still get the proxy error, but it works now all correctly. I will try to play around with the proxy.I am just super happy the website works

1 Like

I don’t know exactly how the visual .env editor does it, but if you click the “raw” tab and there’s only one set of double quotes then it should be good. nice find

1 Like