Open IanMayo opened 1 year ago
I have created an extension inside the souls core folder, and i am now able to render the react app i built from the dist
folder and everything is working fine, but there is some issue with soul
and i had to modify the soul
source code to make this work, here is the extension.
//soul/core/_extensions/api.js
const path = require("path");
const express = require("express");
const reactAdminClient = {
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(path.join(clientPath));
},
};
module.exports = {
reactAdminClient,
};
Soul expects us to create our extension API inside the _extensions
folder and it expects us to provide the path of the folder by using the EXTENSIONS
environment variable, but as you see in here in line 9
the code is reading the _extensions
folder and then it will require the /api.js
file in line 12
, this is not reading the path correctly in development so i have to edit line 12
like this.
- const apiExtensions = require(`${extensionsPath}/${extension}`);
+ const apiExtensions = require(`../${extensionsPath}/${extension}`);
I am still trying to make it work without editing the source code, but even if i change the location of my _extensions
folder to other directories i keep getting the error.
if you are sure about that issue, post it on Soul, please.
ok, i will create an issue
The maintainer has answered my question, the issue was that I was supposed to pass the Absolute path of the _extensions
folder to my .env
file, everything is working fine now. please check the instructions i pushed in the Readme file and let me know if there is anything i have to fix.
We currently have to configure
soul
to overcome CORS requests.But, if we served the static built
react-admin
as asoul
extension, all requests would come from the host url.Extensions are documented here: https://github.com/thevahidal/soul/blob/main/docs/extensions-examples.md
The big-picture is to:
For that deployment strategy, we can probably even simplify the react-admin setup, since we don't need to specify the IP/Port for the soul server - it's the current one 🙂