MoralCode / ClassClock

ClassClock is a free, easy-to-use web app for K-12 schools that provides an at-a-glance view of the school schedule
https://web.classclock.app
GNU Affero General Public License v3.0
33 stars 4 forks source link

Navigating directly to a page leads to a 404 #25

Open MoralCode opened 3 years ago

MoralCode commented 3 years ago

To Reproduce Steps to reproduce the behavior:

  1. click this link to https://web.classclock.app/settings.html

Expected behavior Either settings page should be visible if you have already selected a school or you should see a prompt to select a school.

Actual behavior 404 Error

this seems to be an issue with the redux-first routing model that classclock uses.

this card on the roadmap partly references this problem, but is also combined with the issue of needing to automate builds

polygonnedpotato commented 3 years ago

the reason this happens is because there is no context to opening the file. this means that It can't be opened because it should not even be ready.

MoralCode commented 3 years ago

you mean like this? https://stackoverflow.com/questions/46056414/getting-404-for-links-with-create-react-app-deployed-to-github-pages#46060999 or https://create-react-app.dev/docs/deployment/#serving-apps-with-client-side-routing

When you enter a new URL into address bar of the browser or refreshes the page, browser requests server (in this case GitHub pages server) for that URL. At this point, client side router (react-router) can't take action as it is not yet loaded for that page. Now server looks for a route that matches /accounts won't find it (because routing is done on client side) and returns 404.

Get GitHub pages to redirect to index.html on all requests. Basically you have to add a 404.html in your build directory with code to redirect to index.html. More on how to do that.

MoralCode commented 3 years ago

switching from universal-router to https://github.com/mksarge/redux-json-router#usage may also fix this and provide additional benefits like allowing for a wildcard route path that can lead to a custom classclock-style 404 page on invalid routes.

MoralCode commented 3 years ago

This is fixed in the dev branch and will be part of the next release