SWA Params Payload with Length of 4096 Results in 404

Alex Rankin 50 Reputation points
2025-05-05T14:29:56.88+00:00

Hello,

I noticed late last week that Azure Static Web Apps started returning 404 responses when the length of query params exceeds 4096 characters (including param names and symbols minus "?"). This is a problem for the SPA I host using SWA since my app uses OAuth2.

Any help is appreciated.

Thanks!

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,180 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alekhya Vaddepally 1,670 Reputation points Microsoft External Staff Moderator
    2025-05-06T12:44:16.2+00:00

    Hi Alex Rankin
    Use authority code flow with PKCE through post

    Instead of relying on query strings in redirects, consider switching to post-based authentic flows (if your framework supports it). It is completely avoided from long URL and is a recommended OAuth 2.0 approach to Spa.

    If you are using Microsoft's MSAL.JS or any other popular OAuth client library, enable PKCE (proof key for code exchange) and minimize the state passed in query string.

    Reduce state size or use browser storageIf you are passing the Custom State Parameter in your authentic request, then try:

    State handling in session storage or location,Encoding State Minimum (eg, base 64-encoded json or small identifier) and To avoid large payload or nested objects in the state.This can help keep the final redirected URL under 4096 characters.Store state server-side (advanced)If your app is supported by a serverless API or function app, you can temporarily store complex authentic status on the backend and send a small reference key as Query Param. When redirected, retrieve the full position using that key.

    if you have any further concerns or queries, please feel free to reach out to us.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.