Search code examples
reactjsazurewebreact-routerweb-config

Azure giving error with long URL with Token


I have hosted a front end app using React and React Router Dom to Azure.

I have a reset password link with token as below

https://abc.azurewebsites.net/reset/CfDJ8AkOTLe70aJDl6Jq93G40f4OoMX35xv1bg73%2fU9WyIDfJae9LcF8iFFF6oiO7atp8l9O%2fr1lBq%2bMPZd2aPkELXWPB7YQ5lYoAkh3t2QdB5a%2fB%2bRvJordH34lEbPRBV%2by842E5z%2b1ZNSBstZljGOPZ6tOQNjLGH%2byAAUURGK2Z8rSFjQa22t0RXaVTzP59yCEagf42DGK9UM1PLqtSun655EVkoRH8Jg2LtgK2YZYv6zD

This work fine with localhost. However in Azure it gives this error

"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

I have already added the web.config that was suggested in few posts. It works for shorter URL but not sure how to make it work for bigger urls with tokens.

<?xml version="1.0"?>
<configuration>
  <system.web>
    <customErrors mode="Off"/>
    <httpRuntime maxQueryStringLength = "10000" />
  </system.web>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="React Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
    <security>
      <requestFiltering>
        <requestLimits maxQueryString="10000" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

Solution

  • SOLVED: Please use below. It seems this was a bug and they fixed it in 2019 github.com/Azure/azure-functions-host/pull/3916

    <security> <requestFiltering allowDoubleEscaping="true"> <requestLimits maxAllowedContentLength="104857600" maxUrl="8192" maxQueryString="2048"/> </requestFiltering> </security>