Greedy Proxy Path Does Not Work Locally
See original GitHub issueDescription
Can not use greedy proxy path variable in local SAM server
Steps to reproduce
Using something like this template.yaml.
MyApi:
Type: AWS::Serverless::Api
Properties:
DefinitionBody:
swagger: 2.0
info: { title: !Ref 'AWS::StackName' }
basePath: '/'
schemes: [ 'https' ]
paths:
/:
get:
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}:live/invocations
httpMethod: POST
type: aws_proxy
/{proxy+}:
x-amazon-apigateway-any-method:
parameters:
- name: proxy
in: path
required: true
type: string
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}:live/invocations
httpMethod: POST
type: aws_proxy
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: app.handler
Runtime: ruby2.5
MemorySize: 512
Timeout: 10
Events:
Root:
Type: Api
Properties:
Path: /
Method: GET
RestApiId: !Ref MyApi
All:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
RestApiId: !Ref MyApi
And then using sam local start-api
Observed result
Any root /
request works, but requesting a path like /foo/bar
results in.
2019-03-03 10:59:10 127.0.0.1 - - [03/Mar/2019 10:59:10] "GET /foo/bar HTTP/1.1" 403 -
Expected result
Building and deploying to AWS works. Can it work locally?
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Mac/Darwin
sam --version
: SAM CLI, version 0.11.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Greedy Proxy Path Does Not Work Locally #1037 - GitHub
FWIW, I've been working around this by using /app/{proxy+} . Seem SAM needs some sort of anchor in the path to help it...
Read more >go - Use /path/{proxy+} with AWS SAM to have a greedy API in ...
The reason this doesn't work is that gin receives the path from API Gateway RawPath which in your instance would include "/test".
Read more >Set up a proxy integration with a proxy resource - Amazon API ...
To set up a proxy integration in an API Gateway API with a proxy resource, you perform the following tasks: ... Greedy path...
Read more >404 Unable to identify proxy for host: <virtual host name> and url
Cause: Path not associated with any API proxy. If the API proxy is not configured to accept the requests for the specific path...
Read more >API Gateway Express.js Greedy Paths to a full stack with Vue.js
To get up and running locally, after downloading the source, run npm install in the root directory, then change directories to the guestbook- ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
How can someone test this locally without support for /{proxy+}?
Oh, I do think it might be. Will watch that one to see. Thanks! Closing this one now.