Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{proxy+} path glob not working in local chalice server #2118

Open
bbuechler opened this issue Sep 18, 2024 · 1 comment
Open

{proxy+} path glob not working in local chalice server #2118

bbuechler opened this issue Sep 18, 2024 · 1 comment

Comments

@bbuechler
Copy link

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.

@Ecitperbo
Copy link

Ecitperbo commented Oct 25, 2024

{proxy+} concept is documented here. It is a concept valid for projects using AWS API gateway lambda integration, like chalice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants