title: How to modify incoming response headers using apache?
body: <p>I have a ReactJS application that I produced the production build for, and placed the build folder inside /var/www/html/ (I assume that is the correct way to deploy).</p>
  
  <p>I am calling an API that does not support CORS from this ReactJS application. I found a lot of posts and questions about allowing CORS on apache, but I am not sure if that is what I am looking for. I followed these posts with no luck. I am suspecting these guides are for adding CORS to outgoing responses not incoming?</p>
  
  <p>Anyway, what I added to /etc/apache2/apache2.conf is:</p>
  
  <pre><code>Header always set Access-Control-Allow-Origin "*"
  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"
  </code></pre>
  
  <p>I added these under <code>&lt;Directory /var/www/html&gt;</code></p>
  
  <p>I also tried adding the 4 lines above to .htaccess inside <code>/var/www/html/</code></p>
  
  <p>Again no success.</p>
  
  <p>I want to mention that I have no way to modify the api server, and that I already succeeded in modifying the headers using a middle python flask application. However, I need to eliminate that python app and use Apache for this task.</p>
  
  <p>Is it possible to use apache to modify incoming responses to the server where apache is deployed so that cors is enabled? If yes, what am I missing here?</p>