API deployment to Railway keeps crashing: URI cannot contain options with no value

113 Views Asked by At

As the title says. I've tried to google this line but it brings back like 4 results only and none are useful.

This is how I connect to my mongoDB server

import mongoose from "mongoose";

mongoose.connect(`${process.env.MONGODB_URI}`);

And this is my URI:

mongodb+srv://MY_USERNAME:[email protected]_ID.mongodb.net/ORGANIZATION_NAME?retryWrites=true&w=majority

And then just require his in my index file.

What am I doing wrong to get this issue?

1

There are 1 best solutions below

0
On

Ok I figured it out. When copying my URI into Railway's env variables, something went wrong and it only copied the uri up to retryWrites, leaving out everything after (=true&w=majority). So retryWrites was the option with no value it talked about.