I know a lot of code, but I'm a complete scrub when it comes to xhr.setRequestHeader in html. I've set it up so a user can be logged in using Mozilla's Persona log in, but the console always returns errors:
Refused to set unsafe header "Content-length"
Refused to set unsafe header "Connection"
[Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (sign-in, line 0)
I've set up the html pages... somewhat, but I'd love some help. my website can be found at https://agstp.tk and https://github.com/August712/august712.github.io. Thanks!
(Oh, and can someone explain to me what a header is? As I said, I'm new to this.)
Related
I'm getting the following error when performing any request using anthem:
Refused to set unsafe header "Accept-Encoding"
error
My request is passing the necessary headers and receiving it too:
requisition log
Does anyone have any idea what it could be?
In production the error does not occur
I tried to make the request with several browsers but I was unsuccessful.
I didn't find any other forum reporting the same problem using Anthem.NET
When I upload my code to Infinity Free my CSS and images do not load on the website and I get an error code saying, " Failed to load resource: the server responded with a status of 404 ()" and another error saying, "Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute".
I have linked screenshot of the error messages below and I have linked my websitehttp://laurieelizabeth.infinityfreeapp.com/WDGD150-FinaleAssignment-Java_Canvas/.
PLEASE HELP!
I know the title is contradictory but bear with me.
I have a simple XMLHttpRequest in an MVC app hosted on Azure:-
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.open("GET","http://isni.oclc.org/sru/DB=1.2/query=pica.na+%3DPrince",
false);
xhttp.send();
</script>
this results in a 200 code response and I can see the return page (XML data) using Chrome Network panel. However, I also get the following 2 errors (in the Chrome Console):-
1) Failed to load http://isni.oclc.org/sru/DB=1.2/?query=pica.na+%3DPrince: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mhdatamodel.azurewebsites.net' is therefore not allowed access.
loadDoc # HttpRequest:153
onclick # HttpRequest:89
2) Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://isni.oclc.org/sru/DB=1.2/?query=pica.na+%3DPrince'.
My question is how did I get exactly the response I was expecting (the XML data, the same as if I had just entered the http://... into my browser) and yet get a "Failed to load..." and a "Failed to execute 'send'..." error?
Thanks in advance
I was working with a NodeJS-ReactJS Isomorphic App, and when I click on a Link I'm getting an error saying
Uncaught (in promise) Error: Request has been terminated
Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.
The first two reasons (offline and CORS) I heard about. What is the the page is being unloaded error means? How it may cause the browser not navigating to need.
Your Error is
Uncaught (in promise) Error: Request has been terminated
This error is caused when the request in the promise is terminated before it is resolved or rejected. This can happen if (Possible causes)
the network is offline : There is a network failure and the connection to the url using which the request was being processed is lost.
Origin is not allowed by Access-Control-Allow-Origin : The request is rejected due to absence of proper CORS headers.
the page is being unloaded : The page making the request is closed before the request completed.
Of the above reasons, the most probable cause relevant to your case would be either 1 or 2, since you get the error on clicking a Link to navigate to a component. Please check the requests being made by the new component that is being loaded using the Link.
Edit:
If you look at the error message screen shot, it clearly states that the error occured at line no. 73194 of app.js at PromiseRequest in node_modules/superagent/lib/client.js.Request.crossDomainError. So the reason for your error is a CORS error which is described in number 2 above.
'cause Link component is using Location.push to do the redirection, while Location.push method cannot redirect to another domain.
So my solutions are:
Use window.open('http://your.new.domain.com/index', '_self')
Use <a href="http://your.new.domain.com/index">
It seems you have not enabled the cors in your node server.
Suggested Steps:
npm install cors
use it in app.js (node server)
.
var cors = require('cors');
var app = express();
app.use(cors()); //Enable CORS
I'm using azure Mobile service version "MobileServices.Web-1.1.5.min.js" and when I update a table in database im getting this error on the debug console ("CHROME")
> Refused to get unsafe header "ETag" MobileServices.Web-1.1.5.min.js:2
> getItemFromResponse MobileServices.Web-1.1.5.min.js:2 (anonymous
> function) MobileServices.Web-1.1.5.min.js:2 c
> MobileServices.Web-1.1.5.min.js:2 (anonymous function)
> azureService.js?bust=1400282269337:10 r.onreadystatechange
this did not happened with the older version of the MobileServices.
How to correct this?
Thanks in advance.
The short answer is that you can't do anything to correct it.
This error is browser implementation dependent and you can safely ignore it. It has to do with CORS configuration in Mobile Services. When the update to the table completes successfully, MobileServices sends the updated object back in the response. One of the response headers is "ETag" which some browsers/versions mistakenly identify as dangerous. As far as I know there is nothing you can do to make the console error go away via your code.
If you run the same exact code in Firefox, you will not get the error.
You may just create a PHP "proxy" that uses cURL or file_get_content to fetch the remote content.
You may add the headers Access-Control-Allow-Origin: * or replace the * with your domain-name(s). Last thing is the Access-Control-Expose-Headers that limits the exposure of headers,
for example if you choose to response with access-control-expose-headers:Client-Protocol- your JavaScript based xhr object (for example)
-- calling for xhr.getAllResponseHeaders() will give you pragma, content-type, cache-control, expires (if any exist), skipping few more useful such as Content-Length and X-... ones.. :(