Description
I'm experimenting deploying parse-server and parse-dashboard as serverless express apps in AWS API Gateway/Lambda using the aws-serverless-express
package. parse-server worked well but I ran into an issue with parse-dashboard.
API Gateway adds a stage value to the path of the API URL e.g. https://abc123-api.us-east-1.amazonaws.com/dev where dev
is the API stage. Resources are then mapped as part of the path after 'dev'. In the Lambda handler I mount the the dashboard as an express app at /dashboard:
const dashboard = new ParseDashboard({...});
app.use('/dashboard', dashboard);
A request to https://abc123-api.us-east-1.amazonaws.com/dev/dashboard works for the initial request but fails when it tries to load the login bundle. This is because parse-dashboard/app.js:195 sets the script src to <script src="${mountPath}bundles/login.bundle.js"></script>
which resolves to https://abc123-api.us-east-1.amazonaws.com/dashboard/bundles/login.bundle.js. This URL returns a 403 from API Gateway because it's missing the stage path. Since mountPath is based on where the app is mounted there's no way to know what the original API Gateway path might be.
I fixed this temporarily by adding an ENV variable that allows me to prepend a path to the "mountPath" in app.js but that feels hacky. It works though so if there aren't any other better ideas I could issue a PR for it.
I think there's a huge advantage to supporting deployments of parse-server and parse-dashboard as serverless apps in terms of cost and complexity. Would love to see if there's a better way to fix this issue and make serverless deployments a first class citizen.