Django 301 redirect problem with React

Django 301 redirect problem with React

The answer is: ‘/’

Sometimes when you change your client-side code, and suddenly you experience a 301 redirect response from your server-side.

In my case, I was using Django as a serverside and use ReactJS as a client-side. The API was implemented in a RESTful style.

Most of the cases, the reason was I forgot to end with ‘/’ in my request URL.

(Good) https://api.example.com/api/100/
(Bad) https://api.example.com/api/100

I haven’t really investigated what is behind this rule but, don’t panic and don’t try to dive deep into your serverside code or whatever network related. Just double-check your request URL from the client-side.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: