#reactjs

reactjs 在本地开发使用 proxy 遇到的问题

Published at September 25, 2019 ·  1 min read

在 Reactjs 写前端时遇到的奇葩问题,在 react-scripts start 在 docker 容器中启动,需要在 package.json 中指定 proxy 地址。地址需要保证在reactjs 的容器中能够访问,而非 127.0.0.1:8000 或 localhost:8000 等本地地址。 然而,前后端分离中,后端 API 则在另外一个容器中,所以这里的地址就需要填写对应的地址就需要访问到相应的后端 API。 两种解决方案:1. 在 macOS 的开发环境中可以通过 host.docker.internal 外加端口即可访问宿主机相应的端口服务,2. 通过在 docker-compose 中配置的容器名,即 container_name:port 访问对应的容器资源。...


Tags

abcs accept acid activemq affinity algorithm allocation android array async aws b+tree b-tree backoff benchmark best-practices bfs big-o bigquery bind bitcount blog break broker bubble buffer cache cap cert cgroups channel citus class classmethod cluster concurrency config consumer container context cookie cors crawler cronjob csrf ctr data-science data-structure database datadog dataflow datascience decorator defer dfs distributed django dns docker double-shipping drf ecosia elastic-search enumerate epoll errgroup extra fabric2 facebook-pixel financial-report flask flutter forward-proxy freelance frontend frp garbage-collector gc gcp generator get gil git golang goroutine graphql ha handbook haproxy hash hash-slot hashring hashtable hpa http http-auth http-proxy http_proxy https index init innodb instagram intergration interview ios javascript jinja2 jobboard jwt k8s kafka kibana kqueue label lambda layer4 layer7 lean levels.io linked-list linux list listen loadbalancer logs long-tail lru marketing master matplotlib memory merge metaclass metaprogramming metrics metrics-server microservices mitm model mq myisam mysql namespace nat netflix network-extension nginx nodejs nomad nosql npm oodesign openssl optimization orm pandas parallelism paramiko parkinglot patroni permission pg pipeline pixelme post postgresql postresql prefetch_related prerender private-key process proxy proxycommand put pvm python queue rabbitmq rbac react-native reactive reactjs rebase redis redis-cluster replication resource rest restfulapi retargeting retry revenue reverse-proxy rocketmq rsa rxswift saas scaleable search-engine security select seo serverless service session set shadosocks shadowsocks shard sharding shell shopify sigint signal sigterm slack slave slow-query sniper sns socket socks5 source-code spa sql sqlalchemy sqs ssh ssl ssl-pinning stack startup state stateful stateless staticmethod string struct swift switch syscall system-design systemctl tcp tcp-proxy thread tmpreaper token traefik trustkit tunning type typeform udp variable vc vpn vuejs web web-development where yarn zset 削峰 宽索引 异步 看源码学-golang 窄索引 解耦 跨域 跳板机


Archives

2019 (148)