Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get 404 page after on page reload #66

Open
oussama-he opened this issue Aug 12, 2020 · 1 comment
Open

I get 404 page after on page reload #66

oussama-he opened this issue Aug 12, 2020 · 1 comment

Comments

@oussama-he
Copy link

I deployed an app on Heroku. The app was created using this template.
I have a problem with the app, the problem is: when I navigate to a route like this /catg-1 and after I refresh I get a 404 page.
Note that I use history mode in vue-router.
These are the URL in my Django project:

backend/urls.py

urlpatterns = [

    # http://localhost:8000/
    path('', index_view, name='index'),

    # http://localhost:8000/api/admin/
    path('admin/', admin.site.urls),

    path('api/bookmarks/', include('backend.bookmarks.urls')),

]

backend/bookmars/urls.py

urlpatterns = [
    path('category/', CategoryListAPIView.as_view()),
    path('category/<slug:slug>/', CategoryAPIDetail.as_view(),),
    path('category/<slug:slug>/bookmarks/', BookmarkByCategoryAPIList.as_view()),
    path('bookmark/', BookmarkAPICreate.as_view()),
    path('bookmark/<slug:slug>/', BookmarkAPIDetail.as_view()),
    path('get-page-title/<path:url>', get_page_title_view),
    path('check-url-existence/<path:url>', check_url_existing_view,),
]

And this is the vue.config.js file:

const IS_PRODUCTION = process.env.NODE_ENV === 'production'

module.exports = {
    outputDir: 'dist',
    assetsDir: 'static',
    publicPath: IS_PRODUCTION
    ? 'http://vue-django-bookmark.herokuapp.com/'
    : '/',
    // For Production, replace set baseUrl to CDN
    // And set the CDN origin to `yourdomain.com/static`
    // Whitenoise will serve once to CDN which will then cache
    // and distribute
    devServer: {
      proxy: {
        '/api*': {
          // Forward frontend dev server request for /api to django dev server
          target: 'http://localhost:8888/',
        }
      }
    }
  }

routes from router.js:

export default new Router({
  routes: [
    {
      path: "/",
      component: Home,
      name: 'Home',
    },
    {
      path: "/:category",
      component: Bookmarks,
      name: "Bookmarks",
    },
  ],
  mode: "history",
})

Any help, please?

Thank you in advance.

@gtalarico
Copy link
Owner

Template is not configured to use history mode. You would need either disable history mode or create the proper redirect urls on Django

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants