Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS doesn't work #4313

Closed
GrzegorzZajac000 opened this issue Oct 22, 2019 · 1 comment
Closed

CORS doesn't work #4313

GrzegorzZajac000 opened this issue Oct 22, 2019 · 1 comment

Comments

@GrzegorzZajac000
Copy link

Describe the bug
I have Electron app in which I am using axios for requests. When I am getting request and it return status code 200, everything is okay, but when it returns 404, I can't read error in my app. I set CORS to *, but I can't see any cors headers in response headers. OPTIONS requests returns always 404 :/

Steps to reproduce the behavior

  1. Turn on CORS in Strapi and set origin to *
  2. Make simple app in Electron and try login to API with axios (in main.js of Electron app)

Expected behavior
OPTIONS request should returns 204 with no-content. Any other requests should return CORS headers.

Screenshots
Postman GET response headers: https://www.dropbox.com/s/wx4php43s6eyhyr/Screenshot%202019-10-22%2008.50.10.png?dl=0
Postman OPTIONS request: https://www.dropbox.com/s/y0mj7jk038d4j4j/Screenshot%202019-10-22%2008.53.29.png?dl=0
Strapi cors setting in admin panel: https://www.dropbox.com/s/2tkt1p8xx8398qp/Screenshot%202019-10-22%2008.52.02.png?dl=0

Code snippets

"cors": {
    "enabled": true,
    "origin": "*",
    "expose": [
      "WWW-Authenticate",
      "Server-Authorization"
    ],
    "maxAge": 31536000,
    "credentials": true,
    "methods": [
      "GET",
      "POST",
      "PUT",
      "PATCH",
      "DELETE",
      "OPTIONS",
      "HEAD"
    ],
    "headers": [
      "Content-Type",
      "Authorization",
      "X-Frame-Options",
      "Origin"
    ]
  }

System

  • Node.js version: v10.15.2
  • NPM version: 6.4.1
  • Strapi version: 3.0.0-beta.17.2
  • Database: sqlite
  • Operating system: MacOS Catalina

Additional context
In axios promise even if request return 404, undefined response goes to then instead of catch :/

@GrzegorzZajac000
Copy link
Author

Okay, that's not a problem with CORS in Strapi. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant