CORS Angular 8 it gives me

前端 未结 1 664
情歌与酒
情歌与酒 2021-01-29 09:45

I have a CORS problem in my project. From Angular 8 I do:

 httpOptions = { 
      headers: new HttpHeaders({
        \'Content-Type\':\'application/json\',
              


        
1条回答
  •  情歌与酒
    2021-01-29 10:36

    Angular server runs on http://localhost:4200/ and spring boot server runs on http://localhost:8080/.

    configure a proxy.conf.json parallely to package.json. proxy.conf.json should have

    {
      "/api/*": {
        "target": "http://localhost:8080",
        "secure": false,
        "logLevel": "debug",
        "changeOrigin": true
      }
    }
    

    configure the same in package.json

    "scripts" :{"start": "ng serve --proxy-config proxy.conf.json"}
    

    This configuration should proxy your angular calls to spring boot server. Let me know if this works for you, if you still face any issue, post that error. we could check from there.

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