0

I'm trying to host a node app on www.domain.com/nodeapp. I've already got www.domain.com website hosted on apache server. I've created a reverse proxy in apache configuration.

ProxyPass /nodeapp http://localhost:3100/nodeapp ProxyPassReverse /nodeapp http://localhost:3100/nodeapp 

This is MEAN app's folder structure And below is my node app.js file where I'm linking my angular app in dist folder (which I built using ng build --prod)

app.use("/api/posts", postsRoutes); app.use("/api/user", userRoutes); app.use("/api/client", clientRoutes); app.use("/", express.static(path.join(__dirname, "angular"))); app.use((req, res, next) => { res.sendFile(path.join(__dirname, "angular", "index.html")); }); module.exports = app; 

When I run the node server.js file on port 3000. Only the index.html loads and other static files throws an 404.

I tired then adding an empty base-href ng build --prod --base href while building the angular app which loaded the app with static resources properly but when I navigate in angular app like www.domain.com/nodeapp/auth/login directly in the URL the path of the static file shows www.domain.com/nodeapp/auth/login/style.css which is obviously incorrect. The API links for e.g. (http://localhost:3100/api/posts) doesn't work when accessed using Reverse proxy.

What am I doing wrong here? Is there any working guide where a MEAN app is hosted along side an apache server?

2
  • What is an example of a URL that got a 404? Commented Jul 25, 2019 at 6:52
  • @MichaelHampton It shows www.domain.com/style.234234234242.css for angular app instead of www.domain.com/nodeapp/style.234234234242.css Commented Jul 25, 2019 at 6:54

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.