Search code examples
next.jsiishttpplatformhandler

IIS web site with httpplatformhandler on specific route does not redirect to the nextjs site


I am trying to host a nextjs website on iis here is my set up .

  1. Website with web.config hosted under default site

enter image description here

  1. Contents of web.config which causes nextjs site . On access of http://localhost/AppWithNode1/SimpleErrorView it should redirect to the nextjs site. enter image description here

  2. On navigate to the http://localhost/AppWithNode1/SimpleErrorView it shows the nextjs 404 error page

enter image description here

the console shows 404 for the js and css assets too.

  1. I have tried with adding a basepath to the nextjs.config.mjs and a assetPrefix still get the same error . Im not sure what else is missing to get this to work ? .Any help would be appreciated Thanks . enter image description here

Edit:

enter image description here

Output after rewrite enter image description here

Output from the port hosted via httpplatformhandler

enter image description here

Log file generate output enter image description here


Solution

  • I tested the code you provided and I found that in your nextjs.config.mjs, the value of basepath is still FormsApp, you need to check if it matches your case.

    I also had a situation where static resources couldn't be loaded correctly(404 not found error), but the page.tsx works, I tried using standalone mode and then rebuilding it and it worked, I think you can try it too. Something like this:

    next.config.mjs
    
    module.exports = {
      output: 'standalone',
    }
    

    If this still doesn't work correctly, try creating a plain nextjs app, build and deploy it to see if you have the same problem.