第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

發(fā)布約會(huì)/預(yù)訂 - CORS 政策問題

發(fā)布約會(huì)/預(yù)訂 - CORS 政策問題

瀟湘沐 2023-03-17 16:09:10
我嘗試發(fā)布一本包含預(yù)訂數(shù)據(jù)的字典。但是 chrome 記錄了這個(gè)錯(cuò)誤:Access to XMLHttpRequest at 'http://localhost:8080/reservations' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.這很奇怪,因?yàn)槲铱梢园l(fā)布圖像、視頻、html 內(nèi)容,因?yàn)槲褸CrossOrigin在控制器上方放置了注釋。但是對(duì)于這個(gè)特定的帖子請(qǐng)求,它似乎不起作用。休息控制器:@CrossOrigin(origins="http://localhost:4200",        maxAge=2000,allowedHeaders="header1,header2",        exposedHeaders="header1",allowCredentials= "false")@RestControllerpublic class ReservationsController {    private ReservationDao dao;    @Autowired    public ReservationsController(ReservationDao dao) {        this.dao = dao;    }    @PostMapping("/reservations")    public Map<String, String> bookReservation(@RequestBody Map<String, String> reservation) {        System.out.println(reservation);        return null;    }}angular api bookReservation方法: bookReservation(data) {    console.log(data);    const result = this.http.post(this.apiUrl + 'reservations', data).subscribe(      (val) => {        console.log('POST call succesful value returned in body',          val);      },      response => {        console.log('POST call in error', response);      },      () => {        console.log('The POST observable is now completed');      });    console.log(result);  }
查看完整描述

1 回答

?
jeck貓

TA貢獻(xiàn)1909條經(jīng)驗(yàn) 獲得超7個(gè)贊

如果您只設(shè)置 allowedHeaders,您將允許此參數(shù),如果它收到其他參數(shù),它永遠(yuǎn)不會(huì)發(fā)送交叉原始標(biāo)頭,chrome 將拋出錯(cuò)誤。

如果不需要,則應(yīng)刪除 allowedHeaders、exposedHeaders 和 allowCredentials。


查看完整回答
反對(duì) 回復(fù) 2023-03-17
  • 1 回答
  • 0 關(guān)注
  • 96 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)