Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // server/index.js
- app.use(express.json()); /* Parse json in request */
- /* Priority serve any static files */
- app.use(express.static(path.resolve(__dirname, "../react-ui/build")));
- app.get("/api/send_email", function(req, res) {
- res.set("Content-Type", "application/json");
- /* Send email here */
- res.send('{"message":"Email sent."}');
- });
- /* All remaining requests return the React app, so it can handle routing. */
- app.get("*", function(request, response) {
- response.sendFile(path.resolve(__dirname, "../react-ui/build", "index.html"));
- });
Add Comment
Please, Sign In to add comment