cors

What does exactly is the Microsoft.Owin.Cors middleware when used with ASP.NET Web Api 2.0?

大憨熊 提交于 2019-12-21 04:39:24
问题 I have an ASP.NET Web Api 2.0 project with token authentication and everything done mainly following this article: Token Based Authentication using ASP.NET Web API 2, Owin, and Identity, Bit Of Technology But I am struggling to understand what exactly this line of code in my Startup.cs does: app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); This does not make the Web Api add the Access-Control-Allow-Origin header to my API responses, in other words it does not enable Cors in my Web Api

CORS - http OPTIONS error with Angular and Express

感情迁移 提交于 2019-12-21 04:36:11
问题 I'm trying to make a POST to my API from an Angularjs client, I have this configuration on the server which is running in another domain: app.use(function(req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, OPTIONS, DETELE'); res.setHeader('Access-Control-Allow-Headers', '*'); next(); }); The headers sent to the server are: OPTIONS /api/authenticate HTTP/1.1 Host: xxxx.herokuapp.com Connection: keep-alive Access

How to enable cross origin requests in ASP.NET MVC 4 on POST using Angular 2

試著忘記壹切 提交于 2019-12-21 04:33:36
问题 I'm trying to make a POST request with CORS. I've a class that adds the correct response header on my methods inside my controller using System; using System.Web.Mvc; public class AllowCrossSiteAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "http://localhost:4200"); filterContext.RequestContext.HttpContext.Response.AddHeader("Access

Firebase Cloud Functions https.onCall finished with status code: 204

廉价感情. 提交于 2019-12-21 04:15:14
问题 Firebase Function const functions = require('firebase-functions'); const admin = require('firebase-admin'); const cors = require('cors')({ origin: true }); exports.addMessage = functions.https.onCall((data, context) => { return { text: "Test" }; }); Issue The problem is when i call this function from the app i first get finished with status code: 204 and after that finished with status code: 200 204 How can i prevent this? 回答1: This is normal, and you shouldn't do anything to prevent it. The

How to use Access-Control-Allow-Origin: https://www.example.com?

一笑奈何 提交于 2019-12-21 04:01:22
问题 I want to make HTTPS calls from an HTTP webpage. I hope to solve this problem with Access-Control-Allow-Origin . How can I use it? 回答1: On the HTTPS page (that you are requesting from the HTTP page) set the header: Access-Control-Allow-Origin: http://www.example.com You can do this in PHP with: <?php header("Access-Control-Allow-Origin: http://www.requesting-page.com"); ?> Alternatively if that doesn't work, you could create a file on your HTTP server (where the request is coming from) that

Cross Domain Ajax Call in Atom Shell

痞子三分冷 提交于 2019-12-21 03:58:09
问题 We are working with Atom Shell (Currently known as electron) to wrap a web application as desktop app and having trouble making cross domain ajax calls due to CORS restriction. We also tried nw.js (Formerly known as Node-Webkit) and we had no problem making cross domain ajax call with it. Is Atom Shell (Electron) restricts cross domain calls by default ? 回答1: If the webpage is loaded in "file://" mode and not served by an http server, you can make ajax calls by default. If you still have

Simulate a JSONP response with JavaScript URLs

北战南征 提交于 2019-12-21 03:56:17
问题 I'm using Gravity Forms on a WP site. My forms POST via ajax to Pardot using Pardot form handlers. I am running into an issue where Pardot processes the form 6x, with no other errors. Research indicates that this is because Pardot does not support CORS or JSONP, and thus gets stuck in a loop when using ajax to submit. It's processing the submission but never "finishing" when the form handler's Success URL is set as referring URL. It tries 6x before giving up, processing the submitted data and

Make a CORS request in IE9 with cookies?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 03:36:34
问题 In IE9, I am attempting to make a cross origin request with cookies. However, even when I have the Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Methods all set to the appropriate values (the origin domain, true, and GET, POST), IE9 still isn't sending or setting cookies from the request. Here's the script I'm using: var xdr = new XDomainRequest() xdr.open("http://mydomain.com/cors.php") xdr.withCredentials = true; xdr.send(); Any idea on how to get

grunt-contrib-connect middleware CORS solution with keepalive true

↘锁芯ラ 提交于 2019-12-21 03:33:19
问题 For my local development system I am trying to serve front-end assets using grunt-contrib-connect. I need a cross-domain solution for using fonts in Firefox. The server runs just fine, but I cannot seem to get the headers set. I am using version 0.7.1 of grunt-contrib-connect. connect: { dev: { options: { port: '9001', base: 'build', hostname: 'localhost', keepalive: true, middleware: function(connect, options, middlewares) { // inject a custom middleware into the array of default middlewares

Fail to enable CORS for API Gateway functions

折月煮酒 提交于 2019-12-21 03:26:12
问题 I get While attempting to enable CORS on API Gateway, why is that and how do I resolve this? These functions are deployed using AWS SAM. But I notice if I create my own APIs via AWS Console this happens too The errors looks like: invalid model name specified application/json=Empty invalid response status code specified I found I seem to need to add an "Empty" response model myself? Now, I get Add Access-Control-Allow-Origin Integration Response Header Mapping to POST method (invalid response