我正在执行多个复选框过滤器,并且必须使用post方法将一个对象发送到服务器。我如何使用提取来做到这一点?我可以使用提取发送数据吗?从服务器我必须收到一个过滤列表。谢谢!
我有IIS v8.5,我想配置支持CORS标头.我在web.config中添加了下一个设置:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
</customHeaders>
</httpProtocol>
Run Code Online (Sandbox Code Playgroud)
如果我向我的控制器发出请求它工作正常,但我的文件夹中有java脚本,当我提出获取此文件的请求时,我得到没有标题
"access-control-allow-origin"的响应.我想用该标头提供静态文件.这可能吗?谁能帮我这个?
我有一个 API,目前正在尝试使用其端点之一。端点用于 POST 请求,端点按预期工作。API 在云中运行,我对其进行了测试,curl结果非常完美,然后我试图从我的 React 应用程序中使用它,但我得到了403 status code.
在浏览器的控制台中观看时,我看到我在 OPTIONS 请求中收到该错误,并且 POST 从未完成。这是控制台中显示的结果的屏幕截图:
然后,我用一个表单制作了一个简单的 HTML 文件,在那里我放置了所需的输入,以及指向这个端点的动作,它工作得很好。然后,我不知道错误在哪里?我在 API 中启用了 CORS
在 API 中,我使用 Gorilla/mux,我有这样的东西:
// Set up a router and some routes
r := mux.NewRouter()
r.HandleFunc("/", handleHome)
//some other routes
headersOk := handlers.AllowedHeaders([]string{"*"})
originsOk := handlers.AllowedOrigins([]string{"*"})
methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"})
// Start http server
port := fmt.Sprintf(":%d", SomePort)
http.ListenAndServe(port, handlers.CORS(originsOk, headersOk, methodsOk)(r))
Run Code Online (Sandbox Code Playgroud)
使用:
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
Run Code Online (Sandbox Code Playgroud)
我在浏览器中收到的消息是(西班牙语):
Solicitud desde otro origen bloqueada:la politica de …
nginx配置如下:
server {
listen 80;
listen [::]:80;
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT, PATCH';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Max-Age' 1728000;
server_name erp.dev.thinkerx.com;
access_log /home/thinkerx/nginx/access.log;
error_log /home/thinkerx/nginx/error.log;
location ~ /.well-known {
allow all;
}
# The rest of your server block
root /usr/share/nginx/html/men2017-back-dev/public;
index index.html index.htm index.php;
location /api/ {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; …Run Code Online (Sandbox Code Playgroud) DELETE 方法在 IIS 10 中显示以下错误
请求的资源上不存在“Access-Control-Allow-Origin”标头。
所有其他方法(如 POST 和 GET)都可以正常工作。此外,DELETE 在开发时在 iis express 中运行良好。我为 WebApiConfig 类中的所有请求启用了 cors
public static void Register(HttpConfiguration config)
{
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
// Web API routes
config.MapHttpAttributeRoutes();
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
我的网络配置看起来像这样
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=301879 --> <configuration> <configSections>
<!-- For more information on Entity Framework …Run Code Online (Sandbox Code Playgroud) 我正在使用 AngularJS 编写 Web 应用程序,并且由于 CORS 问题我使用 NodeJS。好吧,当我尝试在我的节点中发出请求时,我收到此错误:
TypeError: https.request is not a function
at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\index.js:56:22
at Layer.handle [as handle_request] (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\express\lib\router\route.js:137:13)
at cors (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:188:7)
at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:224:17
at originCallback (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:214:15)
at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:219:13
at optionsCallback (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:199:9)
at corsMiddleware (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:204:7)
at Layer.handle [as handle_request] (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\express\lib\router\layer.js:95:5)
Run Code Online (Sandbox Code Playgroud)
我的 NodeJS 文件(index.js):
var express = require('express')
var cors = require('cors')
var bodyparser = require('body-parser');
var querystring = require('querystring');
var rootCas = require('ssl-root-cas/latest').create();
rootCas.addFile(__dirname + '/ssl/ovccatastromehes.crt');
const https = require('https').globalAgent.options.ca = rootCas;
var request = …Run Code Online (Sandbox Code Playgroud) 我想将Web推送通知添加到由应用脚本托管的Web应用中。为此,我需要注册服务工作者,并且遇到跨域请求错误。原始内容来自,*.googleusercontent.com而脚本URL为script.google.com/*。
通过使用通过脚本创建的内联URL上的这篇文章,我能够成功创建内联工作器blob。现在,我陷入了在浏览器中注册工作人员的问题。
以下模型适用:
的HTML
<!-- Display the worker status -->
<div id="log"></log>
Run Code Online (Sandbox Code Playgroud)
服务人员
<script id="worker" type="javascript/worker">
self.onmessage = function(e) {
self.postMessage('msg from worker');
};
console.log('[Service Worker] Process started');
})
</script>
Run Code Online (Sandbox Code Playgroud)
内联安装
<script>
function log(msg) {
var fragment = document.createDocumentFragment();
fragment.appendChild(document.createTextNode(msg));
fragment.appendChild(document.createElement('br'));
document.querySelector("#log").appendChild(fragment);
}
// Create the object with the script
var blob = new Blob([ document.querySelector("#worker").textContent ]);
// assign a absolute URL to the obejct for hosting
var worker = new Worker(window.URL.createObjectURL(blob)); …Run Code Online (Sandbox Code Playgroud) javascript google-apps-script web-notifications service-worker
为了克服提交常规 HTTP 请求时遇到的 CORS(跨源请求共享)问题,我需要在 Angular 4 中提交一个隐藏表单。我在 HTML 中做到了这一点,没有任何问题。但是,我不知道如何在 Angular 中做到这一点。这是我的组件 html 中的代码:
<form form #f="ngForm" action="https://whatever.site.I_access" method="get">
<input type="hidden" name="scope" value="openid email">
<input type="hidden" name="response_type" value="id_token token">
<input type="hidden" name="client_id" value="myClientId">
<input type="hidden" name="redirect_uri" value="https://my.redirect.com/">
<input type="hidden" name="nonce" value="aNonceValue">
<button type="submit" (click)="f.submit()">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
在我的 .ts 文件中,我实现了“提交”功能。如果将其留空,则不会提交表单。在此函数中编写的命令是什么,只是为了提交具有指定操作的表单?
onSubmit(){
console.log("form submitted");
}
Run Code Online (Sandbox Code Playgroud)
有什么线索吗?
使用 securityheaders.io 网站,我无法在 apache .htaccess 中识别出引荐来源策略标头。
这是我在 htaccess 中的代码
<IfModule mod_headers.c>
Header set Referrer-Policy "no-referrer"
</IfModule>
Run Code Online (Sandbox Code Playgroud)
该网站仍然说缺少推荐人政策。这不是正确的代码吗?
出现以下错误
Error: self signed certificate
at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:639:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
code: 'DEPTH_ZERO_SELF_SIGNED_CERT',
Run Code Online (Sandbox Code Playgroud)
我正在本地系统中运行该应用程序,我的代码在下面卡住了,请帮助我在node.js应用程序中设置cors,我已经尝试了几件事
var express = require('express');
const axios = require('axios');
var cors = require('cors')
var app = express();
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', req.get('Origin') || '*');
res.header('Access-Control-Allow-Credentials', 'true');
res.header('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE');
res.header('Access-Control-Expose-Headers', 'Content-Length');
res.header('Access-Control-Allow-Headers', 'Accept, Authorization, Content-Type, X-Requested-With, Range');
if (req.method === 'OPTIONS') {
return res.send(200);
} else {
return next();
}
});
app.get('/', function (req, res) {
res.send('Hello World!'); …Run Code Online (Sandbox Code Playgroud) cors ×3
reactjs ×3
iis ×2
javascript ×2
node.js ×2
.htaccess ×1
angular ×1
angularjs ×1
apache ×1
asp.net-mvc ×1
fetch-api ×1
forms ×1
go ×1
gorilla ×1
hidden ×1
http ×1
http-delete ×1
http-error ×1
http-headers ×1
http-post ×1
iis-10 ×1
iis-8 ×1
nginx ×1
post ×1
redux ×1