[Vuejs]-NGINX Django DRF Vue.js POST method returns Method Get not allowed 405

0๐Ÿ‘

โœ…

I have found a solution for this case. For some reason, POST methods were not allowed even though you didnโ€™t have to log in o register to send a contact email. The settings.py of my Django backend app was good. I didnโ€™t specify there anything related to being authenticated. I was able to solve that by adding AllowAny to my views that use POST method. In your views.py first add:

from rest_framework.permissions import AllowAny

Then, you add:

@api_view(['POST'])
@permission_classes([AllowAny])
def contact(request):

So, I am not sure why this is working that way. Even after that, I tried deleting it and it worked well without AllowAny.

๐Ÿ‘คIvan Stepanchuk

1๐Ÿ‘

I suppose that its an Nginx config problem.

This question is related and may help:

POST request not allowed โ€“ 405 Not Allowed โ€“ nginx, even with headers included

Regarding that it works on your local, please Dockerize your app.

๐Ÿ‘คalfawal

Leave a comment