DEV Community

indramanohar
indramanohar

Posted on

NextJS with IIS

I've a NextJS application built with .net core web api as backend with these two running side by side on different ports. While the NextJS app is hosted on NodeJS server a reverse proxy is created for it in IIS so it can be accessed via http port 80/443, web api is hosted on IIS server on a different port 7240 which is accessible only locally to NextJS app. To add to the list, NextJS app is integrated with Azure AD for authentication purposes and everything is tying together well on the server locally after deployment.

However, the problems start when I'm tying to access the NextJS app from internet facing URL using the reverse proxy.

  • The workflow I'm expecting was that NextJS app public URL (reverse proxy) redirects to Azure AD to authenticate users and then based on the reply URL it redirects back to the same public facing URL. But the flow was going to the local hosted app url which is a NEXTAUTH_URL hosted on a specific port 3000.

  • The NextJS app is trying to connect to the web api hosted on port 7240 via public url instead of connecting to it as a local hosted app on the server itself.

I'm somehow unable to figure out how to get this flow working with public url instead of running it on NodeJS default port 3000 which is accessible only on the server.

Can someone please help who has knowledge or experience with this.

Top comments (1)

Collapse
 
bonavida profile image
Diego Bonavida • Edited

To use your environment variables in the client side, you need to define them with a specific prefix NEXT_PUBLIC_.

nextjs.org/docs/basic-features/env...