Cov txheej txheem:

CORS API Gateway yog dab tsi?
CORS API Gateway yog dab tsi?

Video: CORS API Gateway yog dab tsi?

Video: CORS API Gateway yog dab tsi?
Video: 7 - Codeigniter 3 Authenticate Api Request with JWT Token 2024, Hlis ntuj nqeg
Anonim

Pab CORS hauv Amazon API Gateway . CORS pub txoj hauv kev API Gateway rau thov txwv cov peev txheej los ntawm lwm tus sau npe (piv txwv li, tus neeg siv JavaScript uas hu ua API deployed rau ntawm lwm lub npe).

Tsuas yog li ntawd, kuv yuav ua li cas qhib CORS API rooj vag?

Ua kom CORS hauv API Gateway

  1. Mus rau AWS Console.
  2. Mus rau API Gateway.
  3. Nyem rau ntawm koj qhov API.
  4. Nyem rau ntawm txoj kev uas koj xav kom pab CORS rau.
  5. Qhib cov ntawv qhia zaub mov thiab nyem rau ntawm Enable CORS.

Tsis tas li, koj sim Cors li cas? Koj ua tau xeem nws nrog cov neeg siv khoom so zoo li POSTMAN Rest Client, lossis tsuas yog koj tuaj yeem ua tau kuaj nws los ntawm browser console -> Network tab -> hauv xhr lim - kuaj lub header rau qhov kev thov tshwj xeeb. koj ua tau kuaj thov thiab teb. Yog tias koj daim ntawv thov rov qab cov header: Access-Control-Allow-Origin ces nws yuav tsum ua haujlwm.

Ib yam li ntawd, koj daws teeb meem Cors li cas hauv REST API?

Txoj hauv kev los kho qhov teeb meem no muaj xws li:

  1. Ntxiv kev txhawb nqa ntawm OPTIONS txoj kev kom CORS preflight thov siv tau.
  2. Ntxiv rau Access-Control-Allow-Origin header hauv koj cov lus teb kom lub browser tuaj yeem tshawb xyuas qhov kev thov siv tau.

Access Control tso cai rau Keeb Kwm header yog dab tsi?

Nkag mus - Tswj - Tso cai - Keeb kwm yog CORS ( Hla - Keeb kwm Kev sib faib peev txheej) taub hau . Yog tias Site A thov ib nplooj ntawv los ntawm Site B, qhov browser yuav tau txais cov nplooj ntawv thov ntawm qib network thiab xyuas seb cov lus teb puas yog. taub hau sau Site A raws li tus neeg thov kev tso cai sau npe.

Pom zoo: