简体   繁体   中英

How to prevent client from sending an OPTION request before every GET?

在每个GET请求客户端执行OPTIONS请求之前,是否可以以某种方式禁用此行为?

The OPTIONS request is being sent when you're trying to load resources not on the same machine ("same origin policy").

You could:

  1. add a "proxy" script (ie PHP) on the same machine delivering the content that just relays your requests to the other machine. But make sure that nobody misuses your script.

  2. use JSONP if you're fetching data from a JSON-based API. In my opinion, this is the best option.

  3. change the script you're fetching that it can be used as executable code. I mean: make it possible that it can be added via tag in the DOM and sets a variable.

  4. you could add a apache rewrite rule in your apache server if possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM