是否有Digitalocean App Platform上HTTP请求路线的通配符
我有一个我已经构建并部署到Digitalocean应用程序平台的React应用程序。我想知道是否有通配符可以用于HTTP请求路线。我能够为子目录设置路径,但我无法弄清楚如何设置具有Post ID的子目录的路径。
例如:
mywebsite.com/subdirectory->作品,我可以访问此页面
mywebsite.com/subdirectory/12345->当我在子目录之后添加ID时,这无效。
是否有通配符或可以使用子目录和ID访问特定页面的东西。
谢谢
I have a react app I have built and deployed to DigitalOcean App platform. I am wondering if there is a wild card I can use for http request routes. I am able to set paths for subdirectories but I can't figure out how to set up paths for a subdirectory with post ID.
For example:
mywebsite.com/subdirectory -> works and I can access this page
mywebsite.com/subdirectory/12345 -> This doesn't work when I add an ID after the subdirectory.
Is there a wildcard or something I can use for accessing specific pages with a subdirectory and ID.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接回答您的问题:不,似乎不直接支持通配符(至少还没有)。直接在React App中使用通配符并不是常见的设计。通常,您有一个索引页面和一个浏览器路由器或各种后端路由器。
如果是这种情况,并且有一个浏览器路由器,则意味着您实际上没有多个页面,只需index.html,因此您只需将Catchall设置为
index.html
。任何子页面都将被重定向到该页面,然后您的浏览器路由器将呈现适当的组件等。 See DigitalOcean Web - 点用于解释。第二种情况是您确实需要一个复杂的路由,该路由将在需要的地方加载其他HTML文件。在这种情况下,最好将部署在具有NGINX前线之类的容器中。
在这种情况下,您将拥有一个看起来像这样的Dockerfile:
并将其部署为使用Dockerfile的服务。有关如何部署Docker容器的确切说明,请参见DO的网站。 (链接到数字海洋文档)
To directly answer your question: No, it seems like wildcards are not supported by DO directly (at least not yet). It's not a common design to have wildcards directly in React app. Usually you have an index page and an in-browser router or a backend router of sorts.
If this is the case and you have a browser router, it means you don't actually have multiple pages, you just have an index.html, so you can just setup a Catchall to
index.html
. Any subpage will be redirected to that page, and then your browser router will render proper components and such. See DigitalOcean Web-Site for an explanation.Second case is that you do need a complex routing, which will load a different HTML file where you need it. In this case it would be better to deploy in a container with something like an nginx front.
In this case you would have a Dockerfile that looks something like this:
And deploy it as a service with Dockerfile. See DO's site for exact instructions how to deploy a docker container. (Link to Digital Ocean Docs)