最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Serving static assets on local node microservices with caddy - Stack Overflow

programmeradmin0浏览0评论

I have a couple of React applications running locally with WDS on different ports.

  1. landing - running on port 3000 (http://localhost:3000)
  2. account - running on port 3100 (http://localhost:3100)
  3. help - running on port 3200 (http://localhost:3200).

I want to be able to access all of those via port 80, so:

  • http://localhost would direct me to landing app (http://localhost:3000)
  • Any route starting with http://localhost/account would direct me to account app (http://localhost:3100)
  • Any route starting with http://localhost/help would direct me to help app (http://localhost:3200)

I have come up with the following Caddyfile config:

:80 {
  reverse_proxy /account/* localhost:3100
  reverse_proxy /help/* localhost:3200
  reverse_proxy localhost:3000
}

The routing works, but for account pages, the static resources return 404, since the browser attempts to do GET http://localhost/main.css, not GET http://localhost/dashboard/main.css. I did add the base URL to account config, but that didn't help.

发布评论

评论列表(0)

  1. 暂无评论