Note that there are some explanatory texts on larger screens.

plurals
  1. POServicestack Options 404 and Cors Origin
    text
    copied!<p>I am doing a cors request from my</p> <p>client: <code>http://mypcname.companyname</code> </p> <p>to the servicestack</p> <p>server: <code>http://mypcname.companyname:83/customersInformation</code></p> <p>Thats the request with javascript superagent library:</p> <pre><code>superagent.get(requestUrl) .set('Authorization', "basictoken " + getToken()) .set('Accept', 'application/json') .end(function (response) { }); </code></pre> <p>This get request works totally fine with the <strong>Web API</strong>! So the problem can not be the client side in my opinion.</p> <p>Thats my service stack setup:</p> <pre><code>Plugins.Add(new CorsFeature(allowedOrigins: Settings.Default.SmartAllowedCorsOrigin, allowCredentials: true, allowedHeaders: "Content-Type, Authorization")); RequestFilters.Add((httpReq, httpRes, requestDto) =&gt; { if (httpReq.HttpMethod == "OPTIONS") { httpRes.End(); } }); </code></pre> <p>That is how I have setup the class with the customersInformation data:</p> <pre><code>[Route(RouteTemplate,"GET, OPTIONS",...)] </code></pre> <p>Since I use the options request filter from above the option 404 error is gone but now I have something even worse...:</p> <pre><code>OPTIONS http://mypcname.companyname:83/customersInformation Origin http://mypcname.companyname is not allowed by Access-Control-Allow-Origin. </code></pre> <p>What do I have to do on server side to make the cors finally working?</p> <p><strong>UPDATE</strong></p> <p>As Answer to mythz question getting the respone header data:</p> <p>This is the raw data I get as response from the server using the default values on cors plugin: (fiddler <em>raw</em> tab)</p> <pre><code>HTTP/1.1 200 OK Server: Microsoft-HTTPAPI/2.0 Date: Tue, 29 Oct 2013 10:04:48 GMT Content-Length: 0 </code></pre> <p>error in google chrome:</p> <pre><code>OPTIONS http://mypcname.companyname:83/customersInformation Origin http://mypcname.companyname is not allowed by Access-Control-Allow-Origin. </code></pre> <p>The Get method which should be called after the options (thats at least my expectation) is never hit probably due to the cors origion error and because not even the OPTIONS is allowed which happens before.</p> <p><strong>UPDATE 2</strong></p> <p>Request to the server:</p> <pre><code>OPTIONS http://mypcname.companyname:83/customersInformation HTTP/1.1 Host: mypcname.companyname:83 Connection: keep-alive Cache-Control: no-cache Pragma: no-cache Access-Control-Request-Method: GET Origin: http://mypcname.companyname User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 Access-Control-Request-Headers: accept, authorization, x-requested-with Accept: */* Referer: http://mypcname.companyname/ Accept-Encoding: gzip,deflate,sdch Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload