We are running a Flask API (Python Eve specifically), trying to deploy it to AWS via serverless. Here is the serverless.yml:
service: my-api
frameworkVersion: ">=1.1.0"
provider:
name: aws
region: us-east-1
lambdaHashingVersion: 20201221
stage: dev
runtime: python3.9
environment:
...
...
plugins:
- serverless-wsgi
- serverless-python-requirements
functions:
api:
handler: wsgi_handler.handler
events:
- http: ANY /
- http: 'ANY /{proxy+}'
custom:
wsgi:
app: serverless.app
packRequirements: false
pythonRequirements:
dockerizePip: non-linux
configValidationMode: error
The problem arises when sending a request with a query string that contains curly brackets. When running locally with sls wsgi serve
everything works as expected. But when deployed, the same request responds with status code 400
#!/bin/bash
BASE_LOCAL=localhost:5000
BASE_DEPLOYED=https://xxxxxx.execute-api.us-east-1.amazonaws.com/dev
URL_SEGMENT='catalogs/617b10d9e0a92db0e8997dfb?embedded=\{"region":1\}'
# this works
curl -v $BASE_LOCAL/$URL_SEGMENT
# status code 400 from cloudfront (i.e. never made it to the app)
curl -v $BASE_DEPLOYED/$URL_SEGMENT
It works when we urlencode the curly brackets. And this is fine - the cilent application should do this anyways. But is an annoyance when we want to run a quick test, say, with Postman. And it is odd that it is only this deploy model where this happens (deploying the same app via containers/kubernetes, or behind nginx, heck even serving up in the IDE - all works fine).
What is is about the deploy to AWS that is causing curly brackets to be an issue? Is there a way to fix it?