Codeberg/pages-server
26
386
Fork
You've already forked pages-server
54

Routing all paths to index.html #120

Closed
opened 2022年07月28日 08:46:43 +02:00 by dorianim · 2 comments
Contributor
Copy link

Hi!

I recently deployed a react app using codeberg pages. It works fine until you refresh the page at a path other than /. In that case, you get the 404 error page from codeberg.
The reason for that is, that all requests should be routed to index.html to let react handle the routing.

Of course, this not only affects react but all major javascript frameworks.

Maybe it would be possible to always try routing to the index.html in root when a path is not found in the repo?

What do you think?

Hi! I recently deployed a react app using codeberg pages. It works fine until you refresh the page at a path other than `/`. In that case, you get the 404 error page from codeberg. The reason for that is, that all requests should be routed to index.html to let react handle the routing. Of course, this not only affects react but all major javascript frameworks. Maybe it would be possible to always try routing to the index.html in root when a path is not found in the repo? What do you think?
Owner
Copy link

If a path is not found, it return an error 404 by the HTTP spec. Otherwise, search engines will index everything twice and broken links will remain live forever.

Just because "modern web apps" break with the basics doesn't mean that we should do that, too.
And by the way, many other "major javascript frameworks" use a path prefixed with #, e.g. /#/foo/bar. This solves the issue and is compliant with the specs.

We serve the 404.html with error code 404 by default. You can try to use this as a workaround.

If a path is not found, it return an error 404 by the HTTP spec. Otherwise, search engines will index everything twice and broken links will remain live forever. Just because "modern web apps" break with the basics doesn't mean that we should do that, too. And by the way, many other "major javascript frameworks" use a path prefixed with #, e.g. `/#/foo/bar`. This solves the issue and is compliant with the specs. We serve the 404.html with error code 404 by default. You can try to use this as a workaround.
Author
Contributor
Copy link

Using the hash part is really smart, thank you :)

Using the hash part is really smart, thank you :)
Sign in to join this conversation.
No Branch/Tag specified
main
no-not-allow-for-new-users
pages
pages-custom-domain-update
ci_user-local-acme-service
feat/redis-caching
fix/memory-problem
v6.4
v6.3
v6.2.1
v6.2
v6.1
v6.0
v5.1
v5.0
v4.6.3
v4.6.2
v4.6.1
v4.6
v4.5
v4.4
v4.3
v4.2
v4.1
v4.0
v3.2.1
v3.2
v0.3.1
v0.3.0
v0.2.2
v0.2.1
v3.1
v3.0a
v3.0
v2.5b
v2.5a
v2.5
v2.4
v2.3
v2.2
v2.1
v2.0
v1.0_php
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/pages-server#120
Reference in a new issue
Codeberg/pages-server
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?