Correcting Request URLs with Python Serverless Functions

1 min read

At the moment, the URLs of incoming requests to Python Serverless Functions deployed on Vercel are decoded automatically.

Because this behavior is not consistent with a "standalone" Python server, Vercel will stop decoding them for newly created Serverless Functions starting March 2nd, 2021. Existing Deployments will not be affected.

As an example, take a look at the Python Serverless Function code shown above and imagine that the URL of the incoming request ends in /hi%21:

  • With the incorrect behavior, self.path will be set to /hi!.

  • With the updated correct behavior, self.path will be set to /hi%21, which matches the behavior of the built-in HTTPServer class in Python.

To try out this change, define a FORCE_RUNTIME_TAG Environment Variable for your project, set it to canary and create a new Deployment.