Apache 的 CORS 问题

CORS issue with apache

我在向 API 服务器发出请求时遇到问题。 (它以前是有效的),我不确定发生了什么变化,事情似乎是有道理的,但我一定是遗漏了什么。

我尝试查看各种文章和问题,例如 https://dev.to/effingkay/cors-preflighted-requests--options-method-3024 https://awesometoast.com/cors/

  post(platforms, message: string): any {
    console.log("Posting...");
    const data = {
      platforms,
      message
    };

    return this.http.post(`${this.baseUrl}/post`, data);
  }

这里的 php 方法应该是 运行:

    public function post()
    {
        return response(200);

    }

我只想看到返回的 200 响应。但是我会收到以下错误:

    Access to XMLHttpRequest at 'http://my.domain/api/customer-dash/post' from origin 'http://my.domain' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

.htaccess

#always set these headers.
Header always set Access-Control-Allow-Origin "http://my.domain"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"

# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$  [R=200,L]

技术堆栈是 angular、php 和 centos 7 服务器上的 apache

谢谢

我的 services.php 文件中存在语法错误 - 问题已解决