cors

POST request does not work from Angular5 code but works from Postman [duplicate]

扶醉桌前 提交于 2019-12-24 16:15:31
问题 This question already has answers here : Why doesn't adding CORS headers to an OPTIONS route allow browsers to access my API? (29 answers) How does Access-Control-Allow-Origin header work? (14 answers) XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header (7 answers) Closed last year . Frontend: Angular5 Backend: Java (Running on a Wildfly 8.x server) On making an HTTP POST request with content-type: 'application/json' from my Angular application to the server, I get the

AWS API Gateway CORS issue - JS

佐手、 提交于 2019-12-24 16:15:29
问题 Im experiencing abit of problem with CORs request and im not sure what im doing wrong. I use the following code to post to my API Gateway in AWS and its coming back with the following error: "Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response." But in my preflight response, its Access-Control-Allow-Origin is '*' Here is my JS code: <input type="button" id="click" value="Click Me"> <script src="https://ajax.googleapis.com/ajax

NullPointerException when making an OPTIONS request with Access-Control-Request-Method in Spring-data-rest

本秂侑毒 提交于 2019-12-24 15:49:49
问题 I get the following exception when making an OPTIONS request: java.lang.NullPointerException: null at org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping.exposeEffectiveLookupPathKey(RepositoryRestHandlerMapping.java:264) ~[spring-data-rest-webmvc-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping.lookupHandlerMethod(RepositoryRestHandlerMapping.java:165) ~[spring-data-rest-webmvc-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org

XMLHttprequest not working the twitch.tv api

冷暖自知 提交于 2019-12-24 15:49:45
问题 So I've been trying to access the twitch.tv api but every time i go to make a request i keep on getting the error: "XMLHttpRequest cannot load https://api.twitch.tv/kraken/streams/normalice. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8080' is therefore not allowed access." I'm currently using the live-server package during the development process other wise I'm just using html, css, javascript. Here is my javascript: var req = new

Cors requests and MVC5

五迷三道 提交于 2019-12-24 15:35:34
问题 So I have a view on a controller ... [AllowAnonymous] [Route("MyView")] public ActionResult MyView() { // first attempt at solving problem Response.AddHeader("Access-Control-Allow-Origin", "*"); Response.AddHeader("Access-Control-Allow-Headers", "*"); Response.AddHeader("Access-Control-Allow-Methods", "*"); return PartialView(); } I tried adding this attribute (2nd attempt) ... public class AllowCors : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext

CORS issue in node.js failing

房东的猫 提交于 2019-12-24 15:32:54
问题 app.use(function (req, res, next) { // Website you wish to allow to connect res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8100'); // Request headers you wish to allow res.setHeader('Access-Control-Allow-Headers', '*'); // Set to true if you need the website to include cookies in the requests sent // to the API (e.g. in case you use sessions) res.setHeader('Access-Control-Allow-Credentials', true); // Pass to next layer of middleware next(); }); I use postman everything work

CORS request aborted when adding a custom header in AJAX CORS request in IE10

二次信任 提交于 2019-12-24 14:57:35
问题 When I add this header to my jQueryAjax request: headers: { "Authorization": "SomeValue" } on the server I add the Authorization header to the h.Add("Access-Control-Allow-Headers","Authorization"); This works fine in other browsers but not in IE10! ONE REMARK: If I comment out the authentication header, refresh the page, issue a regular GET request to my web api which by default does not trigger a preflight request. After that request, I uncomment the custom header in my jquery request, save,

Access denied when making ajax request in onpaste event

本小妞迷上赌 提交于 2019-12-24 13:52:21
问题 In my asp.net mvc website I am making an ajax call to my server when the user pastes something in a certain textbox. This call used to work in IE 8, but now it stopped working in IE 11, giving me an access denied exception in my jQuery 1.7.1 at h.open(c.type,c.url,c.async) . Long research hinted me that it might be related to a CORS issue, but... every call is on the same domain. <input type="text" id="Pasteexcelhere" name="Pasteexcelhere" /> <script type='text/javascript' > $(function () {

CORS Error - Ajax request returns intermittent failures with NYTimes API

风格不统一 提交于 2019-12-24 13:41:47
问题 I am making several ajax requests to the NYTimes Congress API, whilst iterating over an array of districts (1 to 5). I am only able to successfully return 2 requests on average, the rest returning a: XMLHttpRequest cannot load https://api.nytimes.com/svc/politics/v3/us/legislative/congress/members/house/OR/2/current.json?api-key=xxxxxxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9001' is therefore not allowed access. It appears that

WebAPI CORS and static files

心已入冬 提交于 2019-12-24 13:29:47
问题 I have a WebApi, it is CORS enabled and works nicely. I want to add static files which are served up by the API to be supplementary to the actual WebAPI methods. The static files are served up just fine if you go to them directly, however if I try and ajax them in on another domain I get CORS issues. The actual file in question is a static .html file. I really don't want to create a wrapper controller to serve up static files as it opens a bunch of security concerns if I do it dynamically. I