Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m facing an issue when trying to access one of my microservices behind the express-gateway on a localhost:

Failed to load http://localhost:8080/data: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access.

My gateway.config.yml

  port: 8080
  port: 9876
  hostname: localhost
    host: localhost
    methods: 'GET,POST,PUT' 
    paths: '/data' 
    host: localhost
    paths: '/products' 
    url: 'http://localhost:8282'
    url: 'http://localhost:6000'
  - cors
  - jwt
  - proxy
  - rate-limit
      - data-api
      - cors:
          - action:
              origin: "*"
              methods: 'HEAD,PUT,PATCH,POST,DELETE'
              allowedHeaders: "Origin, X-Requested-With, Content-Type, Accept"
              preflightContinue: true
      - rate-limit:
          - action:                         # allow
              max: 10                       # max 10 request
              windowMs: 120000              # per 120 seconds
      - jwt:
          - action:
              secretOrPublicKeyFile: ./key/pubKey.pem
              checkCredentialExistence: false    

      - product-api
      - proxy:
          - action:
              serviceEndpoint: product-svc 
              changeOrigin: true

Any suggestions?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

NomadXDcommented, Apr 3, 2021

@WesleyFaveri yeah it was like 1 year ago. I think the issue was I haven’t added OPTIONS method to the method list under policies. For a working example , please check this

TietjeDKcommented, Apr 17, 2018

Yes, i removed methods from apiEndpoints: data-api: host: localhost methods: 'GET,POST,PUT' paths: '/data' and it worked

Read more comments on GitHub >

github_iconTop Results From Across the Web

CORS errors and how to solve them - Topcoder
Open a network tab in your console. ... In the response header look for the Access-Control-Allow-Origin header. If it does not exist then...
Read more >
CORS errors - HTTP - MDN Web Docs - Mozilla
If the CORS configuration isn't setup correctly, the browser console will present an error like "Cross-Origin Request Blocked: The Same Origin ...
Read more >
3 Ways to Fix the CORS Error — and How the Access-Control ...
Fix one: install the Allow-Control-Allow-Origin plugin. The quickest fix you can make is to install the moesif CORS extension .
Read more >
CORS not working on Chrome - Stack Overflow
CORS will work in chrome. Just use chrome is safe-mode, i.e., use disable security settings. Google ...
Read more >
What Is a CORS Error and How to Fix It (3 Ways) - Bannerbear
Solution 1: Configure the Backend to Allow CORS · Solution 2: Use a Proxy Server · Solution 3: Bypass the Error Using a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found