Socket.io-client: "Token inesperado

Criado em 14 mai. 2015  ·  5Comentários  ·  Fonte: socketio/socket.io-client

Quando carrego a biblioteca cliente da seguinte forma:

Todos 5 comentários

src="js/socket.io.js"

Tem que ser src="/socket.io/socket.io.js"

Eu recebo o mesmo erro usando este arquivo html:

<!doctype html>
<html lang="en">
<head>
  <!-- The first thing in any HTML file should be the charset -->
  <meta charset="utf-8">
  <!-- Make the page mobile compatible -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Allow installing the app to the homescreen -->
  <link rel="manifest" href="manifest.json">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css">
  <meta name="mobile-web-app-capable" content="yes">
  <title>AP Flora</title>
</head>
<body>
<!-- The app hooks into this div -->
<div id="app"></div>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this HTML file. Don't add any assets here! (Check out webpackconfig.js if you want to know more) -->
<script src="/socket.io/socket.io.js"></script>
<script>
  const socket = io()
  console.log(`socket:`, socket)
</script>
</body>
</html>

O que estou fazendo errado?

funciona quando eu uso:

<script src="https://cdn.socket.io/socket.io-1.4.0.js"></script>

Qual _é_ a url correta?

Chamando socket.io.js localmente, funcionou quando eu uso o browserify para compilar os arquivos necessários corretos. Outra maneira é usar a lib dentro de _socket.io-client_

Esta página foi útil?
0 / 5 - 0 avaliações
bleepcoder.com usa informações licenciadas publicamente pela GitHub para fornecer aos desenvolvedores em todo o mundo soluções para seus problemas. Não somos afiliados à GitHub, Inc. nem a nenhum desenvolvedor que utilize GitHub para seus projetos. Nós não hospedamos nenhum dos vídeos ou imagens em nossos servidores. Todos os direitos pertencem a seus respectivos proprietários.
Fonte para esta página: Fonte

Linguagens de programação populares
Projetos populares do GitHub
Mais projetos GitHub

© 2024 bleepcoder.com - Contact
Made with in the Dominican Republic.
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.