简体   繁体   English

已阻止通过安全连接将地理位置混合访问到https:// localhost:3000,无法访问地理位置

[英]blocked Access to geolocation was blocked over secure connection with mixed content to https://localhost:3000

I have implemented the devise omniauth setup and when I'm signed in with either Facebook, twitter or google the html5 geolocation returns a position unavailable error . 我已经实现了devise omniauth设置,当我用Facebook,Twitter或google登录时, html5 geolocation返回一个position unavailable error But when I'm logged in as regular devise user it works just fine! 但是,当我以常规devise user身份登录时,效果很好! How can I allow access to the html5 geolocation on my rails app when logged in with a social media account? 使用社交媒体帐户登录后,如何允许在Rails应用程序上访问html5 geolocation

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();
}

Update 1 更新1

I changed the code to the following and I'm getting the following errors inside the browser console: 我将代码更改为以下内容,并且在浏览器控制台中收到以下错误:

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}`);
}

Any ideas on how to unblock this? 关于如何解除阻止的任何想法?

This is not a rails issue but a Javascript issue. 这不是Rails问题,而是Javascript问题。 Somewhere in your template, CSS, or Javascript you load something from http instead of https. 在模板,CSS或Javascript中的某个位置,您从http而不是https加载了某些内容。 Use your browser's inspector to find the culprit. 使用浏览器的检查器查找罪魁祸首。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails 5:通过与http:// localhost:3000的不安全连接阻止了对地理定位的访问 - Rails 5: Access to geolocation was blocked over insecure connection to http://localhost:3000 由于与 ionic://localhost 的不安全连接(在 cordova-ios 上),对地理位置的访问被阻止 - Access to geolocation was blocked over insecure connection to ionic://localhost (on cordova-ios) 未阻止从 HTTPS 页面到 HTTP(非 HTTPS)本地主机地址的混合内容请求 - Mixed-content request from HTTPS page to HTTP (non-HTTPS) localhost address not blocked Chrome扩展程序出错-“混合内容:此请求已被阻止; 内容必须通过HTTPS投放” - Error with Chrome extension - “Mixed Content: This request has been blocked; the content must be served over HTTPS” CORS 策略已阻止从源“http://localhost:3000”访问“https://localhost:7144/api/employees” - Access to fetch at 'https://localhost:7144/api/employees' from origin 'http://localhost:3000' has been blocked by CORS policy 混合错误:此请求已被阻止; 内容必须通过 HTTPS 提供 - Mixed Error: This request has been blocked; the content must be served over HTTPS CORS 政策已阻止从源“http://localhost:3000”获取“https://randomuser.me/api/?results=4”的访问权限: - Access to fetch at 'https://randomuser.me/api/?results=4' from origin 'http://localhost:3000' has been blocked by CORS policy: 混合内容 jQuery ajax HTTPS 请求已在 Laravel 上被阻止 - Mixed content jQuery ajax HTTPS request has been blocked on Laravel 在 HTTPS 页面中运行 HTTP AJAX 操作时出现“混合内容被阻止” - "Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page 如何修复受阻止的混合内容的Drupal(https)网站 - How to fix a drupal (https) website with blocked mixed content
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM