1

When should a POST request turn into an an OPTIONS request, and what does that mean? What does the end server see in that case?

I'm trying to get the Save-to-Solr feature of banana working, and failing with a status code of 404. I think this is a CORS problem, but am not sure where to go with it.

Running banana 1.5 as a standalone war in tomcat7 and talking to solrCloud. SolrCloud was (I believe) set up for CORS. Queries for data in the dashboard itself are properly returning data. The collection for banana-int is running on the same server as the collection for logdata.

Having trouble inspecting the POST data from Chrome's Inspect-Element, but stepped through the angular, caught the $http.post(path, data, config), turned this into a command-line POST, and that succeeded in putting the dashboard into Solr. Once the dashboard is manually in Solr, I can then load it from Banana. This tells me things (server url, collection, etc) are wired up correctly from the banana/js perspective.

Chrome screenshot

LizH
  • 445
  • 6
  • 19

1 Answers1

1

This is most likely due to CORS. AngularJS is sending pre-flight OPTIONS request specifying Access-Control-Request-Method: POST in header which tells the server that the upcoming method is POST.

For hints about enabling CORS on Solr, check here: here

aadel
  • 884
  • 8
  • 15
  • SOLR is wired up for CORS, that was necessary to get the log-based queries and loading the dashboard to go through. It seems to be the OPTIONS/POST in particular that is broken. – LizH Feb 25 '15 at 10:19
  • hmmm... try to disable preflight OPTIONS request by replacing 'application/json' with 'text/plain' in the post function inside solr-angular-client.js which would result in sending the POST request directly. – aadel Feb 25 '15 at 10:45
  • Not there, but definitely better. It went through as a POST, but my solr didn't recognize the payload as a valid json update. – LizH Feb 25 '15 at 17:38
  • I think 'text/json' will do. – aadel Feb 25 '15 at 17:50
  • yeah, I tried that. text/json is also turning into an options also. Trying to tinker with the banana-int collection so it treats application/text as json. – LizH Feb 25 '15 at 17:59
  • Success! So using plain\text from the sol-angular-client.js, then rewired the default update handler from solrconfig to point at the json handler and accept plain text. Unformated, but for future reference: application/json text/plain – LizH Feb 25 '15 at 18:03