Egg project receives Post request and returns HTML

When I was learning to use eggs recently, I found a problem. After customizing the post interface, I used postman to test the interface and found that an HTML was returned instead of the test result defined by myself.

Here are the detailed steps:

1. Define the post interface url in the router file, pointing to the post controller.

 2. Write the corresponding processing logic in the corresponding controller (here, write the test return data, and do not write the logic processing for the time being)

 3. After completing the above two steps, in theory, you can get a custom return object with postman test.

For example, the above get request is tested with postman:

But the call result of the post request is different, and an html is returned:

 The console of the project logs a warning:

Click  Security -  Discovery is born for enterprise-level frameworks and applications because of egg's security restrictions.

Referring to the official website example, we add code to disable verification in the configuration file:

 Then open the postman test:

Successfully returns the result we expected. 

Guess you like

Origin blog.csdn.net/qq_42348464/article/details/120949656