{proxy+} path glob not working in local chalice server
From what I can tell, at least with chalice 1.31.2, the {proxy+} glob seems to be broken in the local development server, even though it works properly in AWS. When I try to use nested URLs with this code:
from chalice import Chalice
app = Chalice(app_name='chalice-proxy-example')
@app.route('/')
def index():
return {"message": "Welcome to the root endpoint!"}
@app.route('/resource/{proxy+}', methods=['GET', 'POST'])
def resource_proxy():
return {
"message": "You've accessed the proxy endpoint.",
"path": app.current_request.uri_params.get("proxy+")
}
This happens:
curl http://127.0.0.1:8000/resource/good
127.0.0.1 - - [18/Sep/2024 15:34:52] "GET /resource/good HTTP/1.1" 200 -
{"message":"You've accessed the proxy endpoint.","path":"good"}
curl http://127.0.0.1:8000/resource/still_good/
127.0.0.1 - - [18/Sep/2024 15:36:40] "GET /resource/still_good/ HTTP/1.1" 200 -
{"message":"You've accessed the proxy endpoint.","path":"still_good"}
curl http://127.0.0.1:8000/resource/should_work/but_doesnt
127.0.0.1 - - [18/Sep/2024 15:35:07] "GET /resource/should_work/but_doesnt HTTP/1.1" 403 -
{"message": "Missing Authentication Token"}
curl http://127.0.0.1:8000/resource/should_work/but_doesnt/
127.0.0.1 - - [18/Sep/2024 15:35:10] "GET /resource/should_work/but_doesnt/ HTTP/1.1" 403 -
{"message": "Missing Authentication Token"}
When deployed to AWS, this works perfectly fine. However, in the chalice local server, it won't route.
The weird thing is, I pretty much can't find any documentation for how {proxy+} is supposed to work Chalice. BUT, we have lots of code running the uses it. Is it some weird loophole? The more I try to figure out whats going on, the more lost I get.
{proxy+} concept is documented here. It is a concept valid for projects using AWS API gateway lambda integration, like chalice.
{proxy+}concept is documented here. It is a concept valid for projects using AWS API gateway lambda integration, like chalice.
Right, I wasn't challenging the concept as it exists in AWS, I've used that specific behavior in numerous projects, but rather the implementation in Chalice. In Particular, how the local server implementation behavior does not reflect expected and observed behavior from AWS. Unfortunately, I made this ticket before I realized this project has been hibernated. I've since transition to using powertools.