I know this is a classic issue but I did not find a solution for my particular case. All APIs work fine, while the DELETE API fails with CORS error. This happens only in production environment (OVH web cloud) This is my python backend code:
`class UserDetail(APIView):
permission_classes = (IsAuthenticated,)
def get_object(self, pk):
try:
return User.objects.get(pk=pk)
except User.DoesNotExist:
raise Http404
def get(self, request, pk, format=None):
userSet = User.objects.filter(id=pk)
serializer = UserSerializer(userSet, many=True)
return Response(serializer.data)
def post(self, request, pk, format=None):
userSet = self.get_object(pk)
serializer = UserUpdateSerializer(userSet, data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def delete(self, request, pk, format=None):
user = self.get_object(pk)
user.delete()
return Response({'deleted user': pk}, status=status.HTTP_204_NO_CONTENT)`
This is the .htaccess file put in django root folder:
https://i.stack.imgur.com/NREN0.jpg
If needed, I also share the response header content as displayed by the browser :slight_smile:
https://i.stack.imgur.com/ThiCe.jpg
Error Message:
`Access to XMLHttpRequest at 'https://api.xxxx.com/api/v1/users/11' from origin 'https://xxx.yyyy.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.`
i also read this and implement: https://web-cloud.status-ovhcloud.com/sale
Dedicated Servers - Django Rest Framework - Delete API CORS error in production mode (OVH web cloud)
Related questions
- Blacklisted IP ranges by UCEPROTECTL3
38134
23.02.2021 09:08
- Hot to delete my account?
36500
29.07.2018 19:49
- Proxmox + opnsense
30400
19.07.2018 15:53
- Upcoming change: EFI System Partition over RAID1 for Linux installations
30239
08.10.2025 16:29
- Free easy to setup OpenWRT NAT firewall for OVH (c)ESXi dedicated hosts
30078
16.05.2022 07:18
- Network Resilience Improvement for LACP aggregation on OVHcloud Bare Metal Servers
28720
27.10.2025 11:21
- .iso install on IPMI very slow
27674
22.05.2018 11:14
- Purchased a dedicated server - Awaiting Validation on a Saturday
27569
19.05.2018 20:07
- KVM error, blank screen, not send Keys
27485
11.12.2021 11:45
- Can't cancel/return server
25644
25.06.2018 08:31