码迷,mamicode.com
首页 > 其他好文 > 详细

angular 中配置跨域

时间:2019-10-04 13:18:15      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:core   port   compile   ora   under   package   tor   router   strong   

1. 新建一个 proxy.conf.json

{
    "/search": {
        "target""https://wenku.baidu.com/search",
        "secure"false,
        "changeOrigin"true
    },
    "/getnotice": {
        "target""https://wenku.baidu.com/message/getnotice",
        "secure"false,
        "changeOrigin"true
    },
    "/api": {
        "target""https://wenku.baidu.com",
        "secure"false,
        "changeOrigin"true
    }
}

2. 在 package.json 中

{
  "name""angular-demo",
  "version""0.0.0",
  "scripts": {
    "ng""ng",
    "start""ng serve --proxy-config proxy.config.json",
    "build""ng build",
    "test""ng test",
    "lint""ng lint",
    "e2e""ng e2e"
  },
  "private"true,
  "dependencies": {
    "@angular/animations""~8.1.1",
    "@angular/common""~8.1.1",
    "@angular/compiler""~8.1.1",
    "@angular/core""~8.1.1",
    "@angular/forms""~8.1.1",
    "@angular/platform-browser""~8.1.1",
    "@angular/platform-browser-dynamic""~8.1.1",
    "@angular/router""~8.1.1",
    "axios""^0.19.0",
    "redux""^4.0.4",
    "rxjs""~6.4.0",
    "tslib""^1.9.0",
    "zone.js""~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular""~0.801.1",
    "@angular/cli""~8.1.1",
    "@angular/compiler-cli""~8.1.1",
    "@angular/language-service""~8.1.1",
    "@types/node""~8.9.4",
    "@types/jasmine""~3.3.8",
    "@types/jasminewd2""~2.0.3",
    "codelyzer""^5.0.0",
    "jasmine-core""~3.4.0",
    "jasmine-spec-reporter""~4.2.1",
    "karma""~4.1.0",
    "karma-chrome-launcher""~2.2.0",
    "karma-coverage-istanbul-reporter""~2.0.1",
    "karma-jasmine""~2.0.1",
    "karma-jasmine-html-reporter""^1.4.0",
    "protractor""~5.4.0",
    "ts-node""~7.0.0",
    "tslint""~5.15.0",
    "typescript""~3.4.3"
  }
}

 

angular 中配置跨域

标签:core   port   compile   ora   under   package   tor   router   strong   

原文地址:https://www.cnblogs.com/monkey-K/p/11621837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!