Guest User

Untitled

a guest
Jul 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // server/index.js
  2.  
  3. app.use(express.json()); /* Parse json in request */
  4.  
  5. /* Priority serve any static files */
  6. app.use(express.static(path.resolve(__dirname, "../react-ui/build")));
  7.  
  8. app.get("/api/send_email", function(req, res) {
  9. res.set("Content-Type", "application/json");
  10.  
  11. /* Send email here */
  12.  
  13. res.send('{"message":"Email sent."}');
  14. });
  15.  
  16. /* All remaining requests return the React app, so it can handle routing. */
  17. app.get("*", function(request, response) {
  18. response.sendFile(path.resolve(__dirname, "../react-ui/build", "index.html"));
  19. });
Add Comment
Please, Sign In to add comment