且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AWS Api 网关 + Lambda + 自定义域 (Route53) 缺少身份验证令牌问题

更新时间:2023-12-02 21:25:52

我发现问题是对基本路径映射的工作方式有误解.

I found the issue is misunderstanding of how base path mapping works.

我所有的配置都是正确的.

All my configurations are correct.

我的 API 资源不在/下,而是在/endpoint 下

My API resource is not under / but under /endpoint

要使用自定义域,而不是访问 https://api.{my domain}.com/endpoint,它需要转到 https://api.{my domain}.com/endpoint/endpoint

To use the custom domain, instead of visiting https://api.{my domain}.com/endpoint, it needs to go to https://api.{my domain}.com/endpoint/endpoint

当然这是愚蠢和多余的.

Of course this is silly and redundant.

我有两个选择.我要么设置基本路径映射到/而不是/endpoint,或者我可以只使用 API 资源/而不是/endpoint.

I have two options. I either set up the base path mapping to / instead of /endpoint or I can just user the API resource / instead of /endpoint.

我选择后者,因为如果基本路径映射设置为/,我的 api.{my domain}.com 将只能托管一个 API(我仍然可以使用相同 API 下的资源,但为什么要浪费额外的抽象层?).

I go with the latter because if base path mapping is set to /, my api.{my domain}.com will only be able to host just one API (I can still use resources under the same API, but why wasting the extra layer of abstraction?).

这看起来很糟糕,但我仍然很高兴我想通了.

This seems dump but I am still glad I figured it out.