Sunil Biswakarma
Sunil Biswakarma

Reputation: 129

Angular 2 cli deployment to Github Pages not working.. js file not found

I am unable to deploy my angular 2 app with angular cli: angular-cli: 1.0.0-beta.14 node: 6.4.0 os: darwin x64

The deployed site logs error messages telling that the inline.js, main...bundle.js, styles...bundle.js, favicon.ico Failed to load with status 404. Everything works fine locally but problem starts when in production deploying to Github pages.

The base href is also properly set. May be a problem in CSP??? Kindly guide(Already lost 2 days) Error Screenshot

Upvotes: 2

Views: 730

Answers (1)

Sunil Biswakarma
Sunil Biswakarma

Reputation: 129

Actually I sorted out it just now!

I see that when site is deployed using the ng github-pages:deploy, the site that is generated will have site url like:

xyz.github.io/ng-app

and also the base url will be set like ng-app. Thing I did was set a variable baseUrl: "/ngApp" and set the base url to <base href="{{baseURL}}"> and everything is working now. I guessed that it picked up the app name specified in the angular-cli.json and so it did not match the repo name in github etc... thanks @shusson anyway

Upvotes: 1

Related Questions