site/docs/community/faq.md
If you have questions that is not contained below, please check Egg issues.
Thank you for reporting an issue.
npm init egg --type=simple bug to provide a mini GitHub repository which can reproduce the issue.Most importantly, please understand one thing: the relationship between the user and the maintainer of open source project is not Buyer and Seller, the issue is not a customer order either.
When you're opening an issue, please hold a mentality of "working together to solve this problem." Do not expect us to serve you unilaterally.
Framework Config settings is powerfull, support different environments and different places(framework, plugins, app).
When you got some trouble, and want to find out what is the final config using at runtime, you can checkout ${root}/run/application_config.json(workers' configurations) and ${root}/run/agent_config.json(agent's configurations).(root is application's root directory, in local and unittest environments, it will be project base directory, in other environments will be HOME directory)
Please make sure you don't make a mistake like the code below:
// config/config.default.js
exports.someKeys = 'abc';
module.exports = (appInfo) => {
const config = {};
config.keys = '123456';
return config;
};
By default, logs will print at ${baseDir}/logs(baseDir is project's base directory) in the local environment. But in non-development environments(neither local nor unittest), the logs will print at $HOME/logs(such as /home/admin/logs). So the logs won't mix in during development and locate in the same place when run in production environment.
PM2 as the process management tool?PM2 itself is too complex to issue problems if any.Process management is very important. It defines the way we write code, meanwhile relates to deep runtime optimizations. So we think it's better included in the framework itself.
How to start application with PM2?
Although PM2 is not recommended, you can use it anyway.
Firstly, put a start file in the root directory of your project:
// server.js
const egg = require('egg');
const workers = Number(process.argv[2] || require('os').cpus().length);
egg.startCluster({
workers,
baseDir: __dirname,
});
We can start the application with PM2 like this:
pm2 start server.js
csrf error?There are two kinds of common csrf errors:
missing csrf tokeninvalid csrf tokenBy default @eggjs/security plugin built in Egg requires CSRF validation against all 'unsafe' request such as POST, PUT, DELETE requests.
The error will disappear in the presence of the correct csrf token in the request. For more implementation details, see [../core/security.md#csrf].
Usually this happens when you are using Jetbrains softwares(IntelliJ IDEA, WebStorm, etc.) with Safe Write turned on.
According to Jetbrains Safe Write document:
If this check box is selected, a changed file is first saved in a temporary file. If the save operation succeeds, the file being saved is replaced with the saved file. (Technically, the original file is deleted and the temporary file is renamed.)
Renaming files leads to file watching failure. The solution is simple: just turn of Safe Write option. (Settings | Appearance & Behavior | System Settings | Use "safe write", the path may vary in different versions)