docker ERR_NAME_NOT_RESOLVED http ajax

前端 未结 1 839
傲寒
傲寒 2021-01-20 22:45

I have 3 simple microservices (mysql, apirest, gui) that I start using docker-compose:

version: \'3.2\'
services:
  mysql:
  image: mysql/mysql-server:5.6
           


        
相关标签:
1条回答
  • 2021-01-20 23:03

    AJAX request is the browser request not the server side request and your browser is not a part of mynetwork. To make ajax request (Client browser need to be public domains or map host file with service node port). You still need to map host file in your browser host machine or use full url with service node port in your gui code.

    if you want to avoid using port, proxying is the best way to expose service in my case I am using Nginx

    GUI--- ajax req(browser to server req)----> PROXY(NGINX)---(server to server)--> apirest

    0 讨论(0)
提交回复
热议问题