title: Preflight request doesn't pass access control check: It does not have HTTP ok status problem and i don't know why, i imported everything right
body: <p>I'm getting this error where it says &quot;Response to preflight request doesn't pass access control check: It does not have HTTP ok status.&quot; Anyone have any idea on what could it be?</p>
  <p>This is my code on backend:</p>
  <p>app.js</p>
  <pre><code>app.delete(&quot;api/posts/:id&quot;, (req,res,next) =&gt;{
    console.log(req.params.id);
    res.status(200).json({message: 'post deleted!'})
  })
  
  </code></pre>
  <p>This is the code on frontend:</p>
  <p>posts.service.ts:</p>
  <pre><code>deletePost(postId: string) {
      this.http
        .delete('http://localhost:3000/api/posts/' + postId)
        .subscribe(() =&gt; {
          console.log('deleted');
        });
    }
  
  </code></pre>
  <p>post-list.component.ts</p>
  <pre><code>onDelete(postId: string) {
      this.postsService.deletePost(postId);
    }
  </code></pre>
  <p>And post-list.component.html:</p>
  <pre><code>&lt;button mat-button color=&quot;warn&quot; (click)=&quot;onDelete(post.id)&quot;&gt;DELETE&lt;/button&gt;
  </code></pre>
  <p>Note that I DID ALLOW CORS in my code, here's the proof:</p>
  <pre><code>app.use((req, res, next) =&gt; {
    res.setHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;);
    res.setHeader(
      &quot;Access-Control-Allow-Headers&quot;,
      &quot;Origin, X-Requested-With, Content-Type, Accept&quot;
    );
    res.setHeader(
      &quot;Access-Control-Allow-Methods&quot;,
      &quot;GET, POST, PATCH, PUT, DELETE, OPTIONS&quot;
    );
    next();
  });
  </code></pre>
  <p>Here's a picture of the problem:
  <a href="https://i.stack.imgur.com/4Ap6o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Ap6o.png" alt="Problem" /></a></p>