You can host static content using Soul by utilizing its extensions feature. This allows you to expose your static application through Soul, enabling users to access your content without hosting multiple applications.
Here are diagrams showing how to access Soul APIs when running standalone and how to expose a static client via extensions.
Accessing Soul APIs
Accessing a React Admin Application via Soul
In this guide, we will demonstrate how to host a static React Admin
application.
_extensions
folder and add an api.js
file to it.:
mkdir _extensions && touch _extensions/api.js
Add the following code to the api.js
file:
const reactAdminApp = {
method: "GET",
path: "/api/client",
handler: (req, res, db) => {
const clientPath = path.join(__dirname, "../dist", "index.html");
res.app.use(express.static(path.join(__dirname, "../dist")));
res.sendFile(clientPath);
},
};
Build your React Admin client:
npm run build
Copy the dist
folder from your React Admin
project to the _extensions
folder:
cp -r dist <path/to/_extensions>
soul -d foobar.db --extensions /path/to/_extensions/
http://localhost:<port>/api/client