我已在 AWS API Gateway 上创建了一个 API。我用它来代理静态应用程序,例如名为 Sample-app,我已将其部署到 netlify。
下面附有其openapi配置。
net::ERR_ABORTED 404
我的问题是:
openapi: "3.0.1"
info:
title: "sample-api"
version: "2020-04-29T23:24:23Z"
servers:
- url: "https://sample.com"
paths:
/apps/sample-app/{proxy+}:
x-amazon-apigateway-any-method:
parameters:
- name: "proxy"
in: "path"
required: true
schema:
type: "string"
x-amazon-apigateway-integration:
uri: "https://sample-app.netlify.app/{proxy}"
responses:
default:
statusCode: "200"
requestParameters:
integration.request.path.proxy: "method.request.path.proxy"
passthroughBehavior: "when_no_match"
httpMethod: "ANY"
cacheNamespace: "2ns27y"
cacheKeyParameters:
- "method.request.path.proxy"
type: "http_proxy"
/apps/sample-app:
x-amazon-apigateway-any-method:
responses:
"200":
description: "200 response"
content:
application/json:
schema:
$ref: "#/components/schemas/Empty"
x-amazon-apigateway-integration:
uri: "https://sample-app.netlify.app/"
responses:
default:
statusCode: "200"
passthroughBehavior: "when_no_match"
httpMethod: "ANY"
type: "http_proxy"
我不确定您使用的是 HTTP API 还是 REST API,但如果您使用的是 HTTP API,您可以设置
$default
路由作为包罗万象的方法。
一旦设置了
$default
路线,您的 https://sample.com/apps/sample-app 就应该可以工作了。