我在CF11中创建一个REST服务直到昨晚一切正常,直到我开始在整个地方收到CORS错误。
长话短说这是我的代码:
<cfcomponent rest="true" restPath="/testimonials">
<cffunction name="getTestimonials" access="remote" returntype="any" httpMethod="GET" restPath="/getTestimonials">
<cfargument name="showRatings" type="numeric" restArgSource="Query" default="0">
<cfargument name="siteID" type="numeric" restArgSource="Query" default="0">
<cfargument name="pageID" type="numeric" restArgSource="Query" default="0">
.....
我称之为
<cfhttp url="http://dev.example.com/rest/api/testimonials/getTestimonials" method="GET" result="res">
<cfhttpparam type="URL" name="showRatings" value="0">
<cfhttpparam type="URL" name="siteID" value="17">
<cfhttpparam type="URL" name="pageID" value="2">
</cfhttp>
<cfdump var="#res#">
这是我要回来的返回结构
struct
Charset [empty string]
ErrorDetail [empty string]
Filecontent [empty string]
Header HTTP/1.1 200 OK Access-Control-Allow-Methods: POST,GET,OPTIONS Date: Wed, 23 Sep 2015 08:14:02 GMT Content-Length: 0 Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Origin: * Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET server-error: true
Mimetype Unable to determine MIME type of file.
Responseheader
struct
Access-Control-Allow-Headers Content-Type
Access-Control-Allow-Methods POST,GET,OPTIONS
Access-Control-Allow-Origin *
Content-Length 0
Date Wed, 23 Sep 2015 08:14:02 GMT
Explanation OK
Http_Version HTTP/1.1
Server Microsoft-IIS/8.0
Status_Code 200
X-Powered-By ASP.NET
server-error true
Statuscode 200 OK
Text YES
就我所知,在代码方面或在我的IIS服务器上没有改变以证明此错误。我甚至在我的web.config中添加了下面的代码来尝试启用CORS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Headers" value="Content-Type"/>
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS"/>
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>