title: getServerSideProps causes 500 error when deployed on vercel
body: <p>When I'm running my code in localhost everything works how I want it, but when I run it on vercel it sends a 500: internal server error.</p>
  <p>I've checked my env variables a million times and tried a lot of things but I'm still rather new with this so I feel like I've been running around like a headless chicken.</p>
  <p>any help would be appreciated!</p>
  <p><strong>GitHub:</strong> <a href="https://github.com/IvanDuran02/slagville" rel="nofollow noreferrer">https://github.com/IvanDuran02/slagville</a></p>
  <p><strong>Website:</strong> <a href="https://slagville.vercel.app/" rel="nofollow noreferrer">https://slagville.vercel.app/</a></p>
  <p><strong>getServerSideProps in my index.tsx which then passes message prop into a component</strong></p>
  <pre><code>export const getServerSideProps = async () =&gt; {
    try {
      connectMongo(); // connect to db
  
      const messages = await Message.find(); // fetch messages from database
  
      return {
        props: {
          messages: JSON.parse(JSON.stringify(messages)), // serializing messages or washing turns into string and re parse to JSON
        },
      };
    } catch (error) {
      console.log(error);
      return {
        notFound: true, // returns 404 if error
      };
    }
  };
  </code></pre>
  <p><strong>Error Message that is in Functions section on vercel panel</strong></p>
  <p>[GET] /
  14:35:59:67
  2022-07-23T18:36:00.835Z    219794d0-7b7b-4ddc-8eb6-207359ce9444    ERROR   Unhandled Promise Rejection     {&quot;errorType&quot;:&quot;Runtime.UnhandledPromiseRejection&quot;,&quot;errorMessage&quot;:&quot;MongoParseError: Invalid scheme, expected connection string to start with &quot;mongodb://&quot; or &quot;mongodb+srv://&quot;&quot;,&quot;reason&quot;:{&quot;errorType&quot;:&quot;MongoParseError&quot;,&quot;errorMessage&quot;:&quot;Invalid scheme, expected connection string to start with &quot;mongodb://&quot; or &quot;mongodb+srv://&quot;&quot;,&quot;stack&quot;:[&quot;MongoParseError: Invalid scheme, expected connection string to start with &quot;mongodb://&quot; or &quot;mongodb+srv://&quot;&quot;,&quot;    at new ConnectionString (/var/task/node_modules/mongodb-connection-string-url/lib/index.js:86:19)&quot;,&quot;    at parseOptions (/var/task/node_modules/mongodb/lib/connection_string.js:209:17)&quot;,&quot;    at new MongoClient (/var/task/node_modules/mongodb/lib/mongo_client.js:62:63)&quot;,&quot;    at /var/task/node_modules/mongoose/lib/connection.js:796:16&quot;,&quot;    at new Promise ()&quot;,&quot;    at NativeConnection.Connection.openUri (/var/task/node_modules/mongoose/lib/connection.js:793:19)&quot;,&quot;    at /var/task/node_modules/mongoose/lib/index.js:379:10&quot;,&quot;    at /var/task/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5&quot;,&quot;    at new Promise ()&quot;,&quot;    at promiseOrCallback (/var/task/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)&quot;]},&quot;promise&quot;:{},&quot;stack&quot;:[&quot;Runtime.UnhandledPromiseRejection: MongoParseError: Invalid scheme, expected connection string to start with &quot;mongodb://&quot; or &quot;mongodb+srv://&quot;&quot;,&quot;    at process. (file:///var/runtime/index.mjs:775:15)&quot;,&quot;    at process.emit (node:events:539:35)&quot;,&quot;    at emit (node:internal/process/promises:140:20)&quot;,&quot;    at processPromiseRejections (node:internal/process/promises:274:27)&quot;,&quot;    at processTicksAndRejections (node:internal/process/task_queues:97:32)&quot;]}
  Unknown application error occurred</p>