Abstract : In use Django When developing interfaces , I wrote a book called ping The interface of , It's been debugging all day 404 It's confusing you , Later, I found that if you change the interface name to something else , In the following eyes chrome Intermediate interface name ping That's what happened .
Defining interfaces ping Use Chrome Automatic replenishment upon request ping/ Cause request 404. use drf_ysag
The code of the strange problem is as follows
Use chrome Use in drf_yasg The response to the direct request is as follows , In the right figure, you can see that the server is the recognized request ping/
Use Chrome Browser request , We can see it, too URL There is ping The item , Notice that the detail is a slash after the request . Although or requested is ping, The server redirects it to ping.
Subsequent experimental findings Use Edge There would be no such strange phenomenon .
Now that you find out Chrome Browser automatically ping become ping/ That handle url It's written in ping/ After this change Whether it's chrome still edge All requests can be made Normal response
I put ping Switch to qing Also register routes in the same way as before
then chrome Normal response It doesn't automatically become qing/; It's crazy I've been tossing around for two days !!!