2

My angular cli app works fine with mongodb locally. Locally, I run two services,

 node server.js

on port 3000, and

 ng serve --proxy-config proxy.json

on port 4200.

Now I tried to deploy it on an apache tomcat remote server. I have copied the content from the "/dist" (after running "ng build --prod") folder to server under "apache-tomcat-8.0.47/webapps/", what else?

Open the browser, no data properly got from ":8080/api/models:1

Failed to load resource: the server responded with a status of 404 (Not Found)"

"/api/models:1" should be from running "node server.js" , I guess. Where/how to "scp" "server.js" to server??

Thank you for your help.

This is not the same problem as "Deploy Angular 2 App with Webpack to Tomcat - 404 Errors", mine has server side.

9
  • So you deployed it to apache tomcat remote server, what's the issue...? Commented May 15, 2018 at 14:00
  • @JavascriptHuppTechnologies he said those commands are ran locally. Commented May 15, 2018 at 14:06
  • Ok deleted comment Commented May 15, 2018 at 14:07
  • @penleychan sorry, I added more info. Commented May 15, 2018 at 14:09
  • Are you trying to serve your angular app in production with ng serve? Commented May 15, 2018 at 14:22

1 Answer 1

0

You need to configure your Apache to redirect every request to index.html : on a "regular website", you load one page per URL.

With a single page application, everything is contained into the index file.

Since it's an API link that is the issue, you also need to run a node server. You launched the command correctly and that's great, but now you have to change it.

Serve your node server on another port (let's say 8081), change the URL in your environment.ts file to hit that one, and run node server.js

Sign up to request clarification or add additional context in comments.

3 Comments

This is multiple pages app. I will try it and let you know if it works.
only copy "server.js" to server? where?
Where you can ! Heroku can do it for you, or you can buy a Linux server to deploy your node server on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.