我使用crypto.js进行散列。它之前工作并开始抛出此错误。该应用程序在Linux服务器上使用相同的代码正常工作,但拒绝在我的localhost上启动。这是错误
function WP_Auth( wpurl, logged_in_key, logged_in_salt,
mysql_host, mysql_user, mysql_pass, mysql_db,
wp_table_prefix ) {
var md5 = crypto.createHash( 'md5' );
// line 27 from the error above
md5.update( wpurl );
// end line 27
this.cookiename = 'wordpress_logged_in_' + md5.digest( 'hex' );
this.salt = logged_in_key + logged_in_salt;
this.db = require( 'mysql-native' ).createTCPClient( mysql_host );
this.db.auth( mysql_db, mysql_user, mysql_pass );
this.table_prefix = wp_table_prefix;
this.known_hashes = {};
this.known_hashes_timeout = {};
this.meta_cache = {};
this.meta_cache_timeout = {};
// Default cache time: 5 minutes
this.timeout = 300000;
}
这是wp-auth.js部分
var wp_auth = require('./wp-auth')
.create(config.get('wp:host'),
config.get('wp:LOGGED_IN_KEY'),
config.get('wp:LOGGED_IN_SALT'),
config.get('sql:host'),
config.get('sql:user'),
config.get('sql:password'),
config.get('sql:database'),
config.get('wp:prefix'));
这是我的socket.js调用
"sql":{
"host":"localhost",
"database":"lt_main",
"user":"root",
"password":""
},
"wp":{
"host":"http://forextrader.dev",
"LOGGED_IN_KEY":"my key goes here",
"LOGGED_IN_SALT":"my key goes here",
"prefix":"wp_",
"avatarPath":"my path goes here",
"myCreedApi":"my API key goes here"
},
这是我的配置json
t = new Node
主机参数是我在本地设置的Apache vhost名称。