0

First, the problem is too vague for StackOverflow standards as I probably don't have specific code to show. This is a generic question that I hope someone can help me find out what the problem could be.

I have seen that a base-href is needed in order to tell the project its route in the server. In example, if I want to deploy a project called "project", the base-href should be /project/ and I would access it from 127.0.0.1:port/project/.

So, I have this project I have been working on since months, and I do what I just described above, but the project is not running. I just see the favicon. In order to discard problems, I started a brand new project and followed the same steps to build it to production, and this one, the brand new runs flawlessly. So it means is not a build problem or server problem, but probably my project must have something that is stopping it from running properly.

I wonder if any of you have encounter a similar case and could guide me to find where the problem could be. It is really frustrating that I can't run production after months of work. Any help will be appreciated.

in angular.json I have:

"baseHref": "/project/",
"deployUrl": "/project/",

In xammp, I put the folder created in dist in the htdocs and try to access it from 127.0.0.1:80/project/ (port 80 is open to the server ip). I deploy the project by using this command:

ng build --base-href "/project/" --prod

If you need some extra code to check please let me know.

Germán
  • 1,007
  • 1
  • 7
  • 20
  • If u dont provide your code or at least an example how u set both up, with for example the routing modules and necessary modules, you will get a lot of downvotes until its closed. – sagat Jul 31 '20 at 09:50
  • Will update it with this info now, thanks. – Germán Jul 31 '20 at 09:51
  • does your project lie in the "project"-directory? If not try "/" – Juarrow Jul 31 '20 at 10:34

1 Answers1

0

Following Angular 2 router no base href set, and trying different options, my apps gets to run using the following line in providers in app.module.ts:

{provide: APP_BASE_HREF, useValue : '/project' }

After adding the matching import:

import {APP_BASE_HREF} from '@angular/common';

I don't quite understand what is different in this project that needs this line in order to run, but it is running, so this question is closed (for the time being...).

Germán
  • 1,007
  • 1
  • 7
  • 20