如何设置子域以服务于所有API流量?
我在 example.com
上的一个实例上运行了一个Web应用程序。它在 xpemens.com/api
上具有API。
我想设置一个子域 api.example.com
,并为该子域的所有API流量提供服务。
在单个实例中运行时,如何为子域中的所有API流量服务?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在路由器级别进行设置。看看这个例子
简而言之。
apirouter
它具有所有与API相关的路由。endpoint
直接在主路由器之前,以处理apirouter
的请求。插头的逻辑应该是:
You can set it up at router level. Take a look at this example
https://blog.gazler.com/blog/2015/07/18/subdomains-with-phoenix/
In short.
APIRouter
where it has all API related routes.endpoint
right before the main router to handle requests to theAPIRouter
.The logic for the plug should be: