Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

246
Visualizações
my web share API is supported by chrome in localhost but not supported once I host my website?

while i was working in localhost my web share code is working perfectly but when i hosted my website same code stopped working. my code is still working in localhost server but not in hosted server.

this is my code:

<li class="post-menu-item share_btn" id="'.$post_id.'">Share</li>

actually it is written under php so it has id="'.$post_id.'" in it.

this is my web share API code:

$(".share_btn").click(function(e) {
const post_id = $(this).attr("id");
const link = 'http://localhost/hypeup/post/' + post_id + '/';
if (navigator.share) {
    navigator.share({
            title: 'My awesome post!',
            text: 'This post may or may not contain the answer to the universe',
            url: link,
        }).then(() => {
            console.log('Thanks for sharing!');
        })
        .catch(err => {
            console.log(`Couldn't share because of`, err.message);
        });
} else {
    console.log('web share not supported');
}});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The Web Share API is only available in secure contexts, that is, when your page is loaded over the https: protocol. When you develop locally, the browser considers localhost and 127.0.0.1 etc. to be secure contexts, so for development purposes you don't need to set up https:, only for the production site. You should configure your web server so it redirects people from http: to https:, you can find many ways of doing this summarized in this article.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda