我有一个父 Express 应用程序和一个 Ghost 应用程序作为子应用程序,在这里使用 Ghost 作为 npm 模块。
我将 Ghost 路由到在http://localhost:9000/blog
. 所有配置工作正常(如果未正确提供基本配置,Ghost 将抛出错误)。
这是我的 Ghost 启动代码
ghost({
config: path.join(__dirname, '/config/ghost.config.js')
}).then(function (ghostServer) {
app.use(ghostServer.config.paths.subdir, ghostServer.rootApp);
ghostServer.start(app);
});
这是我的幽灵配置
// # Ghost Configuration
// Setup your Ghost install for various [environments](http://support.ghost.org/config/#about-environments).
// Ghost runs in `development` mode by default. Full documentation can be found at http://support.ghost.org/config/
var path = require('path'),
config;
config = {
// ### Production
// When running Ghost in the wild, use the production environment.
// Configure your URL and mail settings here
production: {
url: 'http://my-ghost-blog.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: '2368'
}
},
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. in RSS and email.
// Change this to your Ghost blog's published URL.
url: 'http://localhost:9000/blog/',
// Example mail config
// Visit http://support.ghost.org/mail for instructions
// ```
// mail: {
// transport: 'SMTP',
// options: {
// service: 'Mailgun',
// auth: {
// user: '', // mailgun username
// pass: '' // mailgun password
// }
// }
// },
// ```
// #### Database
// Ghost supports sqlite3 (default), MySQL & PostgreSQL
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '../blog/data/ghost-dev.db')
},
debug: false
},
// #### Server
// Can be host & port (default), or socket
server: {
// Host to be passed to node's `net.Server#listen()`
host: '127.0.0.1',
// Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
port: '9000'
},
// #### Paths
// Specify where your content directory lives
paths: {
contentPath: path.join(__dirname, '../blog/')
}
},
// **Developers only need to edit below here**
// ### Testing
// Used when developing Ghost to run tests and check the health of Ghost
// Uses a different port number
testing: {
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-test.db')
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing MySQL
// Used by Travis - Automated testing run through GitHub
'testing-mysql': {
url: 'http://127.0.0.1:2369',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'root',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing pg
// Used by Travis - Automated testing run through GitHub
'testing-pg': {
url: 'http://127.0.0.1:2369',
database: {
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'postgres',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
}
};
module.exports = config;
所以基本上,当我去的时候http://localhost:9000/blog
,它根本没有被渲染。没有什么。我正在使用 Chrome 并使用 Safari 对其进行测试。还在没有打开 JavaScript 的情况下测试了这两个。
然后我尝试做curl http://localhost:9000/blog
,并尝试使用请求者应用程序(如 Postman),他们返回了正确的 html 字符串。我还尝试curl
将用户代理用作 Chrome 和 Safari,它也返回正确的 html。
我追查到ghost
node_modules,渲染器就ghost > core > server > controllers > frontend > index.js
在这一行res.render(view, result)
我把它改成了res.render
这样
res.render(view, result, function(err, string) {
console.log("ERR", err);
console.log("String", string);
res.send(string);
})
并且没有错误,它记录当前字符串,但它不会在浏览器上呈现任何内容。
我试过curl,postman,工作,但浏览器不工作。
然后我尝试发送一个hello world
字符串,它可以工作,浏览器呈现它。
然后我将字符串长度一一添加,结果显示,任何str.length < 1023
内容都可以被浏览器渲染,但是一旦超过了,就不行了。
我在我的父 Express 应用程序中尝试过,它能够发送长度超过 1023 的字符串,如果我将 ghost 模块用作独立模块,它也能够发送超过 1023 的字符串。
所以这两者之间一定发生了一些事情,但我不知道如何调试它。
请帮忙