feat(error-page): add a full page for specific errors

This may help people to save their issues

fixes #230
This commit is contained in:
Joxit 2023-02-01 21:54:18 +01:00
parent b9a157c943
commit 6314e8b11e
No known key found for this signature in database
GPG key ID: F526592B8E012263
5 changed files with 94 additions and 12 deletions

View file

@ -71,7 +71,7 @@ export class Http {
req.withCredentials = true;
}
req.hasHeader = hasHeader;
req.getErrorMessage = Http.getErrorMessage;
req.getErrorMessage = getErrorMessage;
self.oReq = req;
req.send();
});
@ -128,15 +128,9 @@ const hasHeader = function (header) {
const getErrorMessage = function () {
if (this._url.match('^http://') && window.location.protocol === 'https:') {
return (
'Mixed Content: The page at `' +
window.location.origin +
'` was loaded over HTTPS, but requested an insecure server endpoint `' +
new URL(this._url).origin +
'`. This request has been blocked; the content must be served over HTTPS.'
);
return { code: 'MIXED_CONTENT', url: this._url };
} else if (!this._url || !this._url.match('^http')) {
return 'Incorrect server endpoint.';
return { code: 'INCORRECT_URL', url: this._url };
} else if (this.withCredentials && !this.hasHeader('Access-Control-Allow-Credentials')) {
return (
"The `Access-Control-Allow-Credentials` header in the response is missing and must be set to `true` when the request's credentials mode is on. Origin `" +