<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sarvesh Sakpal</title>
    <description>The latest articles on DEV Community by Sarvesh Sakpal (@sarvesh_sakpal_b7927153c1).</description>
    <link>https://dev.to/sarvesh_sakpal_b7927153c1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4048109%2F615d566e-e587-4db4-b521-e84462ec5b76.png</url>
      <title>DEV Community: Sarvesh Sakpal</title>
      <link>https://dev.to/sarvesh_sakpal_b7927153c1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sarvesh_sakpal_b7927153c1"/>
    <language>en</language>
    <item>
      <title>That CORS error? It wasn't my code</title>
      <dc:creator>Sarvesh Sakpal</dc:creator>
      <pubDate>Sun, 26 Jul 2026 15:52:01 +0000</pubDate>
      <link>https://dev.to/sarvesh_sakpal_b7927153c1/that-cors-error-it-wasnt-my-code-5d7e</link>
      <guid>https://dev.to/sarvesh_sakpal_b7927153c1/that-cors-error-it-wasnt-my-code-5d7e</guid>
      <description>&lt;p&gt;I learned something interesting while debugging Apache, Express, and CORS.&lt;br&gt;
Seeing a CORS error in the browser doesn't necessarily mean your Express CORS configuration is broken.&lt;br&gt;
I had a frontend sending requests to an API through Apache:&lt;br&gt;
Frontend → Browser → Apache → Express (server.js)&lt;br&gt;
The browser was showing a CORS error.&lt;br&gt;
My first thought was naturally:&lt;br&gt;
“Something must be wrong with my CORS configuration.”&lt;br&gt;
But the interesting part was that the request wasn't even reaching server.js.&lt;br&gt;
That changed how I looked at the problem.&lt;br&gt;
CORS is enforced by the browser. If Apache, a reverse proxy, or another layer returns/fails with a response that doesn't contain the expected CORS headers, the browser can surface it as a CORS error.&lt;br&gt;
So:&lt;br&gt;
Browser shows CORS error ≠ request definitely reached your application.&lt;br&gt;
Another thing I learned while debugging the same proxy setup was the importance of forwarded headers.&lt;br&gt;
My flow looked like:&lt;br&gt;
Browser → HTTPS → Apache → HTTP → Express&lt;br&gt;
Apache terminates HTTPS, so Express's direct connection can be HTTP even though the client originally connected using HTTPS.&lt;br&gt;
That's where:&lt;br&gt;
X-Forwarded-Proto: https&lt;br&gt;
becomes important.&lt;br&gt;
It tells the backend that the original client connection was HTTPS.&lt;br&gt;
And on the Express side:&lt;br&gt;
app.set("trust proxy", 1)&lt;br&gt;
tells Express to trust proxy information according to the configured proxy topology.&lt;br&gt;
This becomes especially important with things like:&lt;br&gt;
cookie: { secure: true }&lt;br&gt;
because your application needs to correctly understand whether the original request was secure.&lt;br&gt;
A useful debugging lesson I took from this:&lt;br&gt;
Don't debug only the error shown by the browser. Debug the entire request path.&lt;br&gt;
Browser → DNS/TLS → Reverse Proxy → Application → Response → Browser&lt;br&gt;
Sometimes the error you see at the frontend is only the symptom, not where the actual failure happened.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>react</category>
      <category>apache</category>
    </item>
  </channel>
</rss>
