admin管理员组文章数量:1122832
So I'm currently developing a Google Chrome extension in Node.js. As part of the extension, I'm making calls to the OpenAI API, and I'm building a backend for these calls to be done securely on AWS Lambda. I'm using Terraform to build the Lambda configuration, which uses an AWS API Gateway. This is the TF CORS configuration for the API gateway:
resource "aws_apigatewayv2_api" "http_api" {
name = "ExpressAPI"
protocol_type = "HTTP"
cors_configuration {
// Extension ID comes from mimic extension on Chrome
allow_origins = ["chrome-extension://<chrome-extension-id>"]
allow_methods = ["OPTIONS", "POST"]
allow_headers = ["Content-Type", "Authorization"]
}
}
When I include this in the TF configuration and run "terraform apply", I get the following error:
│ Error: updating API Gateway v2 API (<aws-account-id>): operation error ApiGatewayV2: UpdateApi, https response error StatusCode: 400, RequestID: <request-id>, BadRequestException: Invalid format for origin chrome-extension://<chrome-extension-id>
│
│ with aws_apigatewayv2_api.http_api,
│ on lambda.tf line 18, in resource "aws_apigatewayv2_api" "http_api":
│ 18: resource "aws_apigatewayv2_api" "http_api" {
I get the same error when I try to include the extension url (chrome-extension://) in the AWS console, obviously including the actual chrome extension id where the placeholder is. So my question is, how do you get a Google Chrome extension to access an AWS Lambda function via an Express API and its endpoints? Since AWS doesn't seem to allow a chrome-extension origin.
I've read that this can be done with an HTTPS proxy server with something like NGINX in order to handle the CORS layer and to allow the chrome-extension:// origin. Is this the best way to do it, or is there a more simple way to go about this. Any insight would be appreaciated, thanks!
本文标签:
版权声明:本文标题:How can I get a Google Chrome extension to call an AWS Lambda function that uses AWS API Gateway? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306185a1932864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论