Angular 学习笔记 ( 链接服务器 )

ng 是做前端开发的, 所以通常我们会配上一个 API server. 

本地调试时通常使用 proxy 

https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md

proxy.conf.json

{
    "/api": {
      "target": "http://192.168.1.101:61547",
      "secure": false
    },
    "/uploadedFiles": {
      "target": "http://192.168.1.101:61547",
      "secure": false
    },
    "/download-file": {
      "target": "http://192.168.1.101:61547",
      "secure": false
    },
    "/OAuth" : {
      "target": "http://192.168.1.101:61547",
      "secure": false
    }
  }
  

package.json 

"start": "ng serve --proxy-config proxy.conf.json --host 192.168.1.101"
 
 
后端 ASP.NET (vs2017) 部分
refer : https://stackoverflow.com/questions/22044470/bad-request-invalid-hostname-while-connect-to-localhost-via-wifi-from-mobile-ph
1. 开 firewall port Inbound
2. C:\Projects\<ProjectName>\.vs\config\applicationhost.config‌ (这个是 hide 的哦) 
<site name="Project" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\keatkeat\projects\freeland\dotnet\Project" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:61547:localhost" />
        <binding protocol="http" bindingInformation="*:61547:192.168.1.101" />
    </bindings>
</site>

3. run as admin vs2017 

posted @ 2018-01-31 23:45  兴杰  阅读(321)  评论(0)    收藏  举报