title: CORS Problem - preflightMissingAllowOriginHeader - Express Gateway and Axios
body: <p>I'm tyring to use Express Gateway + AXIOS (react) + Express, but I'm receiving the CORS Erro, I already did many thing but nothing worked.</p>
  <p>The error is this:
  <a href="https://i.stack.imgur.com/LL0Kt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LL0Kt.png" alt="enter image description here" /></a></p>
  <p><code>Cross-Origin Resource Sharing error: PreflightMissingAllowOriginHeader</code></p>
  <p>My <code>EXPRESS</code> is like this:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const corsOptions = {
      origin: '*',
      methods: ['POST', 'GET', 'PATCH', 'DELETE'],
      allowedHeaders: ['Content-Type', 'Authorization']
  }
  app.use(cors(corsOptions));</code></pre>
  </div>
  </div>
  </p>
  <p>My <code>EXPRESS-GATEWAY</code>:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>http:
    port: 8080
  admin:
    port: 9876
    host: localhost
  apiEndpoints:
    api:
      host: "localhost"
      paths: 
        - '/api/B/*'
        - '/api/A/*'
  serviceEndpoints:
    appname:
      urls: 
        - 'http://localhost:8000'
  policies:
    - jwt
    - cors
    - expression
    - log
    - proxy
    - rate-limit
  pipelines:
    default:
      apiEndpoints:
        - api
      policies:
        - cors:
            - action:
                origin: ["*"]
                methods: [ "HEAD", "PUT", "PATCH", "POST", "GET", "DELETE" ]
                credentials: true
                allowedHeaders: ['Content-type','Authorization','Origin','Access-Control-Allow-Origin','Accept','Options','X-Requested-With']
        - jwt:
            - action:
                secretOrPublicKey: code
                checkCredentialExistence: false
        - proxy:
            - action:
                serviceEndpoint: appname
                changeOrigin: true</code></pre>
  </div>
  </div>
  </p>
  <p>My <code>AXIOS</code>:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const headers = {
    headers: {
      "Authorization": authToken,
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Credentials": true
    },
  }
  
  axios.get(`${API_PRIVATE_URL}/user/profile`, {
    crossdomain: true
  }, {
    withCredentials: true
  }, headers)</code></pre>
  </div>
  </div>
  </p>
  <p>I don't know what to do anymore. Can someone help me ?</p>
  <p>I already went in several posts but nothing worked..</p>
  <p>edit: It didn't go to controller neither.
  edit2: I can use with POSTMAN, and it worked as expected...</p>