Dynamic url rendered by Django as an api response, but not by frontend

I'm using Django + Angular, and I have a dynamic url which works for first time when load my product page. I specified as a dynamic url in Django too, so the url look like this "product/home/:productName/:productId". Everything definitely works but as a response when I reload my page, it gets plain API response from Django and the host is changed to the backend one. Why it's happening? I was searching around didn't found anything.


path('product/home/<str:handle>/<int:id>', ProductGet)


def ProductGet(request, handle, id):
    product = Product.objects.get(id=id)
    serializer = ProductSerializer(product, many=False)
    return JsonResponse(serializer.data, safe=False)

So, this code works for first time, but then when I reload seems it changes host to Django and I'm getting as a response, my API response. enter image description here

So, something with browser and framework host where angular didn't understand a request.So the fix.


import {HashLocationStrategy, Location, LocationStrategy} from '@angular/common';

providers: [
  {provide: LocationStrategy, useClass: HashLocationStrategy}
Back to Top