Javascript 通过与的混合内容的安全连接阻止了对地理位置的访问https://localhost:3000

Javascript 通过与的混合内容的安全连接阻止了对地理位置的访问https://localhost:3000,javascript,ruby-on-rails,geolocation,omniauth,Javascript,Ruby On Rails,Geolocation,Omniauth,我已经实现了Desive omniauth设置,当我使用Facebook、twitter或google登录时,html5地理位置会返回一个位置不可用错误。但当我以普通Desive用户的身份登录时,它就可以正常工作了!使用社交媒体帐户登录时,如何允许访问rails应用程序上的html5地理位置 function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosit

我已经实现了Desive omniauth设置,当我使用Facebook、twitter或google登录时,html5地理位置会返回一个位置不可用错误。但当我以普通Desive用户的身份登录时,它就可以正常工作了!使用社交媒体帐户登录时,如何允许访问rails应用程序上的html5地理位置

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(setGeoCookie,showError);
    } else {
        alert("Geolocation is not supported by this browser.");
    }
}


function showError(error) {
switch(error.code) {
    case error.PERMISSION_DENIED:
        window.location = window.location;
        window.alert("Permission denied");
        break;
    case error.POSITION_UNAVAILABLE:
        window.location = window.location;
        window.alert("Location information is unavailable.");
        break;
    case error.TIMEOUT:
        window.location = window.location;
        window.alert("The request to get user location timed out.");

        break;
    case error.UNKNOWN_ERROR:
        window.location = window.location;
        window.alert("An unknown error occurred.");
        break;
}
location.reload();
}
更新1

我将代码更改为以下内容,在浏览器控制台中出现以下错误:

Origin does not have permission to use Geolocation service
[blocked] Access to geolocation was blocked over secure connection with mixed content to https://localhost:3000.


function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(success, error, options);
    } else {
        alert("Geolocation is not supported by this browser.");
    }
}


var options = {
    enableHighAccuracy: true,
    timeout: 5000,
    maximumAge: 0
};

function success(pos) {
    var crd = pos.coords;

    console.log('Your current position is:');
    console.log(`Latitude : ${crd.latitude}`);
    console.log(`Longitude: ${crd.longitude}`);
    console.log(`More or less ${crd.accuracy} meters.`);
}

function error(err) {
    console.warn(`ERROR(${err.code}): ${err.message}`);
}

有没有关于如何取消阻止的想法?

这不是rails的问题,而是Javascript的问题。在模板、CSS或Javascript中的某个地方,您可以从http而不是https加载某些内容。使用浏览器的检查器查找罪犯

你在本地主机上运行这个吗?否则,您的网站将通过http从localhost加载一些资产,迫使浏览器判定该网站不安全,并拒绝访问地理位置。另外,这是一个javascript问题,而不是RoR问题。感谢@Tim Lawrenz的回复。我正在运行这个https://localhost:3000 像这样:rails服务器puma-b'ssl://0.0.0.0:3000?key=server.key&cert=server.crt'. 我怎样才能弄清楚到底是什么问题?