Add docs for hosting a static content
This commit is contained in:
@@ -168,6 +168,10 @@ npm run dev # Start the dev server
|
||||
|
||||
Make sure to replace the placeholders with the appropriate values for your environment.
|
||||
|
||||
## Hosting Static Content Using Soul
|
||||
|
||||
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. please check [this](./docs//self-hosting.md) document
|
||||
|
||||
## Community
|
||||
|
||||
[Join](https://bit.ly/soul-discord) the discussion in our Discord server and help making Soul together.
|
||||
|
||||
BIN
assets/images/soul-RA-app.png
Normal file
BIN
assets/images/soul-RA-app.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
BIN
assets/images/soul-standalone.png
Normal file
BIN
assets/images/soul-standalone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
55
docs/self-hosting.md
Normal file
55
docs/self-hosting.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Hosting Static Content Using Soul
|
||||
|
||||
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**
|
||||
|
||||

|
||||
|
||||
## Steps
|
||||
|
||||
In this guide, we will demonstrate how to host a static `React Admin` application.
|
||||
|
||||
1. Create an `_extensions` folder within the `Soul` directory and add a file named `api.js`:
|
||||
```sh
|
||||
mkdir _extensions && touch _extensions/api.js
|
||||
```
|
||||
2. Add the following code to the `api.js` file:
|
||||
|
||||
```js
|
||||
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);
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
3. Build your React Admin client:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
4. Copy the `dist` folder from your `React Admin` project to the `_extensions` folder:
|
||||
|
||||
```sh
|
||||
cp -r dist <path/to/_extensions>
|
||||
```
|
||||
|
||||
5. Run your Soul application:
|
||||
```sh
|
||||
npm run dev
|
||||
```
|
||||
6. To verify that the app is working, open the following URL in your browser:
|
||||
```
|
||||
http://localhost:<port>/api/client
|
||||
```
|
||||
Reference in New Issue
Block a user