Hi Back4App users!
This tutorial explains how you can deal with routes of JS frameworks as React, Ionic, Angular at Back4App that are not being handled correctly. Please, check the steps below:
Step 1 - Create the file and paste the code
Firstly, create a file called as app.js
and add the code below:
let path = require("path");
let express = require("express");
app.use(express.static(path.join(__dirname, 'public')));
app.get("*", (req,res)=> {
res.sendFile(path.join(__dirname, 'public/index.html'));
});
Step 2 - Access your Cloud Code section
After following step 1, you have to upload it to Back4App. To do so, go to Back4App website, log in, click on My Apps
section, find your app and click on Server Settings > Cloud Code > Settings. The “Could Code” block looks like this:
Or you can click on DASHBOARD
. After that, click on Core
> Cloud Code Functions
.
Step 3 - Select the file and upload it
Either way, you will end up at cloud code functions section at the dashboard, simply click on the + ADD
button and select the app.js
the file you created previously, then click on the DEPLOY
button.
At this point, you are able to test your Web app.
If you still facing this issue, please contact our team via chat!
Comments
0 comments
Please sign in to leave a comment.