Skip to content
zuowenjian edited this page Sep 26, 2016 · 3 revisions

API如何解决跨域问题?

通过拦截器可支持

  class  AccessAllow  extends XInterceptor
  {
      public function _after($xcontext,$request,$response)
      {
          header("Access-Control-Allow-Origin: *");
          header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
      }
  }

bootstrap.php

  XAop::append_by_match_uri(".*", new AccessAllow());
Clone this wiki locally