Ad

Django React -- Deployment Error On Heroku (Page Not Found 404)

I'm deploying my Django React project to Heroku. Build was successful, but when I visit the site which is https://django-react-app-nba.herokuapp.com/, I'm getting django-react-app-nba.herokuapp.com/:14 GET https://django-react-app-nba.herokuapp.com/static/frontend/main.js net::ERR_ABORTED 404 (Not Found)

(Development for this project followed this tutorial https://www.valentinog.com/blog/drf/#Django_REST_with_React_Django_and_React_together)

ServerError (GET https://django-react-app-nba.herokuapp.com/static/frontend/main.js net::ERR_ABORTED 404 (Not Found))

I don't understand why Django is even looking for this URL, could anyone enlighten me?

Server Error

My Project Files Path

My Project Files Path

nbavoting urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path("admin/", admin.site.urls),
    path("", include("frontend.urls")),
    path("", include("teams.urls")),
    path("", include("users.urls")),
]

frontend urls.py

from django.urls import path
from . import views

urlpatterns = [path("", views.index)]

frontend views.py

from django.shortcuts import render

def index(request):
    return render(request, 'frontend/index.html')

My guess to the problem is that the router in the frontend is conflicting with server-side routing? (I'm using HashRouter in React)

Ad

Answer

You forgot to run "npm run build" :D

Ad
source: stackoverflow.com
Ad