title: HTTPS Redirect in next js
body: <p>I'm trying to do a http to https redirect using next, 
  so if the user enters the site at <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a> redirect to <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a>
  I'm using GraphQL Yoga on the server side, so not sure how I could accomplish this in my index file on the server side.
  I've tried using the meta tag and changing the protocol in the window object but no luck with doing so in server-side rendering.
  Is there any way I can accomplish this redirect on the client side using next js or on the server side?</p>
  
  <pre><code>const cookieParser = require('cookie-parser')
  const jwt = require('jsonwebtoken')
  require('dotenv').config({path: '.env'})
  const createServer = require('./createServer')
  const db = require('./db')
  const sslRedirect = require('heroku-ssl-redirect');
  const server = createServer()
  //Express middleware to handle cookies
  server.express.use(cookieParser())
  //decode JWT 
  server.express.use((req, res, next) =&gt; {
      const { token } = req.cookies;
      if (token) {
        const { userId } = jwt.verify(token, process.env.APP_SECRET);
        req.userId = userId;
      }
      next()
  })
  //Populates user on request
  server.express.use(async (req, res, next) =&gt; {
    if(!req.userId) return next()
    const user = await db.query.user({
      where: {id: req.userId}
    }, `{id, permissions, email, name}`)
    req.user = user
    next()
  })
  //start
  server.start({
       cors: {
          credentials: true,
         origin: process.env.FRONTEND_URL
      },
  }, starting =&gt; {
      console.log(`server is running on port ${starting.port}`)
  })
  </code></pre>