gofractally / psibase

Open source protocol enabling communities to easily self-host web applications
https://docs.psibase.io
MIT License
28 stars 7 forks source link

Allow SPAs with registered http server to serve rest endpoints #881

Closed James-Mart closed 1 month ago

James-Mart commented 1 month ago

Shortcoming with the http server impl was discovered specifically when dealing with SPAs:

For example: Chainmail is registered as an SPA, so any request that doesn't specify an extension (which would imply a request for a static asset e.g. style.css) it assumes is a client route and returns the root document. But that means that API requests like /messages/sender=alice are just returning the root document.

This PR reverses the order in which the servers are checked, checking the registered server first. Only check sites iff the registered server returns None.