Ich habe eine AngularJS und NodeJS (API) -Anwendung. Ich hatte bereits CORS auf meinem NodeJS mit CORS() Nodejs-Bibliothek aktiviert.AngularJS NodeJS Cors Probleme hinter Firewall
Ich habe die erforderlichen Header eingefügt, um auch CORS zu aktivieren.
Ich habe CORS Problem nur, wenn ich die Website von meinem Firmencomputer zugreifen. Es funktioniert gut von meinen Personal Computern. Kann mir bitte jemand sagen, was ich falsch mache. Jede Hilfe oder Anregung bitte.
Chrome Konsolenprotokolle:
-------------------- Headers ----------------- ----
Allgemein:
Request URL:www.example.com:81/api/getdata
Request Method:GET
Status Code:503 Service Unavailable
Remote Address:111.111.11.111:81
Antwort-Header:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Length:973
Content-Type:text/html; charset=UTF-8
Expires:Thu, 01 Jan 1970 00:00:00 GMT
P3P:CP="CAO PSA OUR"
Pragma:no-cache
Anforderungsheader:
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:www.example.com:81
Origin:http://www.example.com
Referer:http://www.example.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
-------------------- Antwort: --------------- -----
<html>
<head>
<title>Web Page Blocked</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<meta name="viewport" content="initial-scale=1.0">
</head>
<body bgcolor="#e7e8e9">
<div id="content">
<h1>Web Page Blocked</h1>
<p>Access to the web page you were trying to visit has been blocked in accordance with company policy. Please contact your
system administrator if you believe this is in error.</p>
<p><b>User:</b> </p>
<p><b>URL:</b> www.example.com:81/api/getdata </p>
<p><b>Category:</b> unknown </p>
</div>
</body>
</html>
Browser Console Fehler:
XMLHttpRequest cannot load http://www.example.com:81/api/getdata . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://www.example.com ' is therefore not allowed access. The response had HTTP status code 503.
------ ----- EDIT Hier ist die cors() ich bin vorbei.
app.options('*',cors());
app.use(function (req, res, next){
res.header("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, PATCH, DELETE");
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, PATCH, DELETE");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With,Content-type, Accept");
res.header("Access-Control-Allow-Credentials", true);
next();
});
Meine Vermutung wäre, dass Ihr Unternehmen blockiert Port 81. Nichts mit Ihrer Anwendung zu tun . – Duncan
Danke für die Antwort, ich würde es mit einem anderen Port versuchen. – user3479754