Client routing not working when deployed to IIS sub application using httpPlatformHandler
Unanswered
American Chinchilla posted this in #help-forum
American ChinchillaOP
I have followed this guide to getting a nextjs 14 application using SSR running under a sub domain in IIS
https://docs.lextudio.com/blog/running-next-js-web-apps-on-iis-with-httpplatformhandler/
My web.config looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="" verb="" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Program Files\nodejs\node.exe" arguments=".\node_modules\next\dist\bin\next start">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
<environmentVariable name="NODE_ENV" value="Production" />
<environmentVariable name="NEXT_PUBLIC_BASE_PATH" value="/NextApp" />
</environmentVariables>
</httpPlatform>
</system.webServer>
My app is then accessed at the path /NextApp
This all works, but when switching between routes using the Next Link component the full page is reloading every time rather than just the nested route page being returned. This is resulting in any state managed via React's Context API to be reset and not persisted between routes.
How can I resolve this?
#help-forum
https://docs.lextudio.com/blog/running-next-js-web-apps-on-iis-with-httpplatformhandler/
My web.config looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="" verb="" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Program Files\nodejs\node.exe" arguments=".\node_modules\next\dist\bin\next start">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
<environmentVariable name="NODE_ENV" value="Production" />
<environmentVariable name="NEXT_PUBLIC_BASE_PATH" value="/NextApp" />
</environmentVariables>
</httpPlatform>
</system.webServer>
My app is then accessed at the path /NextApp
This all works, but when switching between routes using the Next Link component the full page is reloading every time rather than just the nested route page being returned. This is resulting in any state managed via React's Context API to be reset and not persisted between routes.
How can I resolve this?
#help-forum