getCorsUrl = function (url, requestHeaders, expectedResponseHeaders, basePath = "/") {
	if (!url || url.length < 1) {
		throw new Error(`Invalid URL: ${url}`);
	} else {
		let corsUrl = `${location.protocol}//${location.host}${basePath}cors?`;

		const requestHeaderString = getRequestHeaderString(requestHeaders);
		if (requestHeaderString) corsUrl = `${corsUrl}sendheaders=${requestHeaderString}`;

		const expectedResponseHeadersString = getExpectedResponseHeadersString(expectedResponseHeaders);
		if (requestHeaderString && expectedResponseHeadersString) {
			corsUrl = `${corsUrl}&expectedheaders=${expectedResponseHeadersString}`;
		} else if (expectedResponseHeadersString) {
			corsUrl = `${corsUrl}expectedheaders=${expectedResponseHeadersString}`;
		}

		if (requestHeaderString || expectedResponseHeadersString) {
			return `${corsUrl}&url=${url}`;
		}
		return `${corsUrl}url=${url}`;
	}
}
Gets a URL that will be used when calling the CORS-method on the server.
@param {string} url the url to fetch from
@param {Array.<{name: string, value:string}>} requestHeaders the HTTP headers to send
@param {Array.<string>} expectedResponseHeaders the expected HTTP headers to receive
@param {string} basePath, default /
@returns {string} to be used as URL when calling CORS-method on server.