ruby on rails - Cors Requests for POST and PUT and PATCH and so on are not working. Only GET -


I have a rail app, which has an API that people can use Unfortunately that AP apparently Only requests received and nothing to do, I tried a POST request, for which you do not have to certify.

My BaseController , which is extracted from ApplicationController , is used by all API controllers. It looks like:

  module API module V1 class basin controller & lt; ApplicationController response_to: json before_action: default_json rescue_from ActiveRecord :: RecordNotFound, with = & gt; : Record_not_found after_filter: cors_access Provide access to everyone from protected APIs #defcors_access if request.subdomain == "API" header ['access-control-permission-original'] = '*' header ['access-control- Request-method '] =' * 'End end and end end  

The main URL for some api.sitename.com/api/v1/what/x/ I can get the request okay, but when it comes to posting, I get:

  XMLHttpRequest not loaded Can http: //api.w Riter.aisisplatform.com/api/v1/posts/16/comments/. There is no 'Access-Control-Permission-Origin' header on the requested resource Origin 'http: // localhost: 9000' therefore entry is not allowed  

then why do I request a GET Can I not POST request?

To use the spinal cord, you need to make an adjustment in sync, this is something Also:

  (function (backbone) {var methods, _sync; _sync = Backbone.sync; methods = {beforeSend: function () {return.trigger ('sync: start', this );}, Complete: function () {return.trigger ('sync: stop', this);}}; Backbone Sync = function (method, entity, options) {var sync; if (options == null) options = {}; _.defaults (options, {beforeSend: _.bind (methods.before send, entity), complete: _ Bind (methods.complete, entity)}) // add crossdomomain if (! OptionsCrossDomain) options. Add crossDomain = true; // xhrFields (! Options.xhrFields) {options.xhrFields = {with credentials: true};} = _sync (method unit, option); if (! Entity._fetch & amp; Method === 'reading') return unit. _fet = sync;};}) (backbone);  

By default, all requests made from the spinal cord are of GET, POST requires you to send object objects in the fetch:

  models = New backbone.model (); Model.fetch ({url: 'http://api.com/uri', type: 'POST'})  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -