-
-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable CORS error for localhost #910
Comments
I had assumed that this was a blocking error, and not just a simple message, so I never bothered clicking the "Load from URL" button and ended up running my own docker image 🤦 A simple fix would be to test the hostname of the url too: const getUrlParams = (url: string) => {
let protocol: string | undefined;
let isLocal = false;
try {
const urlObj = new URL(url);
protocol = urlObj.protocol;
isLocal = /^(localhost|\[::1\]|127(.[0-9]{1,3}){3})/i.test(urlObj.hostname);
} catch (err) {
}
return {protocol, isLocal};
}
const {protocol, isLocal} = getUrlParams(url);
...
else if (
protocol &&
protocol === "http:" &&
window.location.protocol === "https:" &&
!isLocal
) { |
Feel free to submit a PR, I'll be happy to review it. |
See maplibre#910 Don't show CORS warning for localhost
The Vite server supports configuration of CORS. That is when you start development with See:
|
When trying to add a source with http, you always see this message:
However this is even the case for
http://localhost
, even though CORS does not apply to localhost (I never had any problems at least). This error should not be shown when the host islocalhost
.The text was updated successfully, but these errors were encountered: