Tag: 谷歌浏览器

Node.js – 资源解释为脚本,但以MIMEtypestext / plain传输

首先:我没有使用Express。 这样一来,当我加载我的index.html文件recursionreadFile每个附加的文件,如我的CSS和JS页面。 但它总是在我的督察(Chrome)中返回这个错误: 资源解释为脚本,但以MIMEtypestext / plain传输 我完全不知道为什么这样做。 这是我的代码: var http = require('http'); var querystring = require('querystring'); var fs = require('fs'); var url = require('url'); function route(handle, pathname, response, request){ console.log("About to route a request for " + pathname); if (typeof handle[pathname] === "function"){ handle[pathname](response, request); } else { var file_path = ""; // parses the […]

无头铬代理服务器设置

任何人都可以帮助我设置代理服务器无头铬,而在这里提到的Node.js使用灯塔铬启动器 const launcher = new ChromeLauncher({ port: 9222, autoSelectChrome: true, // False to manually select which Chrome install. additionalFlags: [ '–window-size=412,732', '–disable-gpu', '–proxy-server="IP:PORT"', headless ? '–headless' : '' ] }); 但是,上面的脚本根本不打我的代理服务器。 Chrome似乎回退到目标网站的DIRECT://连接。 另一个讨论在无头镀铬的情况下使用HTTP / HTTPS代理服务器的资源是这样的 。 但它没有给出任何如何使用Node.js的例子。

Google chrome vs nodejs(v8)的性能?

例 console.time("Test"); for(var i=0; i <2500000; i +=1 ){ // loop around } console.timeEnd("Test"); 上述代码在nodejs运行faster比google chrome faster 。 为什么node.js比谷歌铬都快,都使用chrome v8引擎 注意 平均速度 Google Chrome – 1518.021ms Node.js – 4 ms 任何关于差异执行速度的想法?

Chrome开发工具“save”在debuggingnode.js应用程序时不工作

在debuggingchrome开发工具( http://youtu.be/03qGA-GJXjI )中的node.js cli脚本的同时,我无法保存我在网上debugging普通javascript时所做的更改。 我收到一条错误消息: “Debugger.setScriptSource失败。LiveEdit失败:无法编译新版本的脚本:SyntaxError:Unexpected token [” 然后警告: 实时编辑更改回源文件被configuration禁用。 在config.json中更改选项“saveLiveEdit”以启用此function。 有谁知道如何解决这一问题? debugging和编辑文件并保存,而不离开chrome开发工具是非常方便的。 谢谢。 顺便说一句,这是config.json的样子, https://github.com/node-inspector/node-inspector/blob/master/config.json 。 我尝试将“saveLiveEdit”选项更改为true,但仍然得到相同的消息:“通过configuration禁用实时编辑更改回源文件,在config.json中更改选项”saveLiveEdit“以启用此function。

针对超时POST请求的浏览器重试行为不一致

由于超时,服务器没有响应时,我偶尔会遇到POST请求重试。 所有现代浏览器都有幂等请求(GET,HEAD等)的重试逻辑,但是我无法理解为什么会发生POST请求。 我正在testing这种情况下使用一个简单的node.js服务器3路由和铬浏览器。 / : gives a html page with jquery and code snippets to fire ajax requests /hi : gives a text response 'hello' /sleep : request will timeout without any response 默认情况下,node.js http服务器在2分钟后超时请求。 retry.js var http = require('http'); var server = http.createServer(); server.on('request', function(req, res) { console.log(new Date() + ' ' + req.method […]

Chrome DevTools错误:“无法保存到临时variables。”

我正在使用Node Monkey来debugging我的NodeJS应用程序。 经常发生的情况是,当我在我的Chrome控制台中点击“存储为全局variables”时,显示“无法保存到临时variables”。 console.log({why:'dont', you:'work?'}) 它也发生在这个jsfiddle 1)我做错了什么? 2)为什么发生这种情况? Chrome:50.0.2661.102(64位)OSX El Capitan 10.11.4

如何使用Advanced REST Client或PostmantestingExpress / node REST API后端?

我需要testing我的REST API后端接受JSON与先进的REST客户端或Postman为Chrome。 但是我遇到了问题:我只能使用内置表单发送请求,并使用Content-Type:application / x-www-form-urlencoded 但是这样做不起作用,因为我embedded了文档,例如, 我需要POST这个 : {title:"Awesome post!", tags: ["blue", "jeans"] } Chrome扩展的内置表单无法实现。 当我selectRaw Body并在其中插入内容时,我的后端将req.body视为一个空对象。 当我还设置标题“Content-Type:application / json”时,我在后端得到以下错误: SyntaxError: Unexpected token n at Object.parse (native) at IncomingMessage.exports.parse.application/json (/Library/WebServer/Documents/slipfeed/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:135:16) at IncomingMessage.EventEmitter.emit (events.js:85:17) at IncomingMessage._emitEnd (http.js:366:10) at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23) at Socket.socket.ondata (http.js:1682:22) at TCP.onread (net.js:404:27) 注:我在我的应用程序的configuration中使用bodyParser()和methodOverride()。 禁用他们没有帮助。 我应该使用哪些设置,以便我可以将JSONinput到原始正文字段,并且请求会起作用? 为了澄清答案:我必须设置Content-Type:application / json(在请求标题中)并使用格式良好的json,其中属性名称也在双引号内部以使其工作。

要求没有定义? 的node.js

开始使用nodej.s 在我的app / js文件中,我正在做这样的事情 app.js var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Am I really running a server?!'); }).listen(8080, '127.0.0.1'); console.log('running server!'); 当我在我的terminal,并运行node app.js 控制台吐出'running server!' 但是在我的浏览器中,我得到了Uncaught ReferenceError: require is not defined 有人可以向我解释为什么在terminal,它工作正常,但在浏览器中,它不? 我使用npm http-server来服务我的页面。

Access-Control-Allow-Origin不允许源http:// localhost:3000

XMLHttpRequest cannot load http://localhost:8080/api/test. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. 我阅读了关于跨域的Ajax请求,并了解了底层的安全问题。 就我而言,2台服务器在本地运行,并且喜欢在testing期间启用跨域请求。 localhost:8080 – Google Appengine dev server localhost:3000 – Node.js server 我正在向localhost:8080 – GAE server发出一个ajax请求,而我的页面是从节点服务器加载的。 什么是最简单,最安全的(不想用disable-web-security选项启动Chrome)。 如果我必须更改'Content-Type' ,我应该在节点服务器上执行吗? 怎么样?