简体   繁体   English

为什么 XML 会成为 MEAN 堆栈应用程序的问题,这个错误是关于什么的?

[英]Why would XML be an issue with a MEAN stack application, and what is this error about?

I am currently working on a socket.io "hello world" via a MEAN stack application, and right away Chrome is tossing some funky errors my way.我目前正在通过 MEAN 堆栈应用程序开发 socket.io“hello world”,Chrome 马上就抛出了一些奇怪的错误。 To be honest, in the debugging effort, I'm not sure even where to begin.老实说,在调试工作中,我什至不确定从哪里开始。 My initial questions were:我最初的问题是:

  • Why is XML being used instead of JSON?为什么使用 XML 而不是 JSON?
  • What does No 'Access-Control-Allow-Origin' header is present on the requested resource.请求的资源上不存在“Access-Control-Allow-Origin”标头是什么意思 even mean?甚至是什么意思?

The entire error message is below, and thanks in advance for any advice y'all are able to give.整个错误消息如下,提前感谢你们提供的任何建议。

Cheers,干杯,

Peter彼得

XMLHttpRequest cannot load http://localhost/socket.io/?EIO=3&transport=polling&t=1435600202687-6. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 404.

Try including the socket.io lib directly from the socket server:尝试直接从套接字服务器包含 socket.io 库:

<script src="http://localhost:9000/socket.io/socket.io.js"></script>

The Error "No 'Access-Control-Allow-Origin' header is present on the requested resource."错误“请求的资源上不存在‘Access-Control-Allow-Origin’标头。” means that your server doesn't allow an extern resource to connect.意味着您的服务器不允许外部资源连接。

Additionally you can set the allowed origins directly in the io setup eg:此外,您可以直接在 io 设置中设置允许的来源,例如:

var io = require('socket.io')(server, {origins:'page.com:* http://page.com:* http://www.page.com:*'});

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM