Does anyone have any ideas on what I'm doing wrong and need to change either in the angular built files or in my routes (where to add the static or new routes) ?An express application (with typescript) which acts as the API, when not running this locally I deploy to heroku.An Angular 8 application which is the front-end and uses the API, when not running this locally I use the ng cli to create a production build which I deploy to netlify.I would like to unite these two and have my express application (both locally and on heroku) serve the production build of the Angular FE.This has proven tricky for me and I haven't found any good examples.I can create a folder and use express.static() to serve it, it works with your usual html file but not with my app and not with my route structure.This is an example of what the front end files that I'm trying to serve look like.What I think further complicates matters is my routing structure (which is different from most "serve this files from express" tutorials which setup a simple all-in-one-file server)In main.tsapp.use("/", routes); Then in routes.tsimport { Router } from "express"; import userRoutes from "./users/userRoutes"; import friendshipRoutes from "./friendships/friendshipRoutes"; import messagesRoutes from "./messages/messagesRoutes"; const routes = Router(); routes.use("/users", userRoutes); routes.use("/friendship", friendshipRoutes); routes.use("/messages", messagesRoutes); export default routes; For example messagesRoutes.tsimport { Router, Request, Response, response } from "express"; import MessagesCtrl from "../../controllers/messagesController"; import { IMessage } from "../../models/IMessage"; import PubSub from "pubsub-js"; const messagesRoutes = Router(); const messageCtrl: MessagesCtrl = new MessagesCtrl(); messagesRoutes.post("/get-conversation", // rest of function ); export default messagesRoutes; Does anyone have any ideeas on what I'm doing wrong and need to change either in the angular built files or in my routes (where to add the static or new routes) ?
Submitted February 15, 2020 at 07:24PM by Hero_Of_Shadows
No comments:
Post a Comment