Closed ghost closed 7 years ago
Finally got to the bottom of this one, it had nothing to do with the middleware, I had done two stupid things, noted below along with the steps to find them in case it helps anyone afterwards:
Added a typo to a variable name on the way past so headers were empty - no real hints for help with finding fat fingers
I did find that by setting the line below in my app.config (temporarily for debug) I could clear all custom headers and get simple POST request so no OPTIONS preflight call, I then just had to debug the request to identify which custom headers I needed to add to the list for the headers.allow array on the middleware. For me it turned out to be as below, will vary depending on your API and client requirements though:
"headers.allow" => ["Content-Type", "Authorization", "Accept", "Origin", "Headers", "Method"],
Hi Mika,
Thanks for all the tireless work you put into these repos, I'm currently using your CORS-Middleware and planning to use the JWT or BRANCA on in due course.
I have a really annoying issue which I'm sure is an easy fix but I can't find it, using Slim 3.8.1 with Cors-Middleware 0.5.2 I am getting CORS errors on the POST but not GET calls. I'm trying to develop the UI with Ionic (via Ionic Creator) so using AngularJS. Using inspect I can see the headers being set on the GET as below, GET doesnt appear to issue an OPTIONS call, not sure if that's correct or not:
But using POST I can see them being set as below on the OPTIONS call:
I've implemented the middleware as below, I've added a few permitted origins including evil.com due to using browser extension for debugging, I get the issues when that is switched off:
Have I missed something that is obvious in how to make it fire the middleware on the OPTIONS or preflight request?
Thanks for any help you can offer, I've been using SLIM for a while but not much on middleware yet, also first time I've hit CORS pain. My plan for production is to deploy API to one server, UI to another for use on mobile browsers and then a mobile app that will go straight to the middleware.
Any thoughts most welcome! Thanks