Skip to content

Deploying to github pages with custom domain is not working correctly #4127

Closed

Description

@TautvydasDerzinskas

Please provide us with the following information:
When deploying Angular-cli application it uses repository name to define a base path. This is an issue when you deploy application to Github repository witch has custom domain enabled for it's Github pages.

You still need to define repository name to get app deployed but in such case you wouldn't want to have that name as absolute path of your application.

""
in index.html should become
"<base href="{{ REPOSITORY NAME or "/" if custom domain is enabled }}">"

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
All OS

Versions.

angular-cli: 1.0.0-beta.25.5
node: 7.3.0
os: win32 x64

Repro steps.

  1. Have a repository where Github pages setup uses custom domain
  2. Deploy your app (app must contain components)
  3. Test it

The log given by the failure.

Application tries to load component files using such link structure:

{{ Custom domain}}/{{ Repository name }}/{{ Rest of the path to the component files }}
(I did bold out the problematic part)

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

Activity

  1. MrGrigri commented on Jan 20, 2017

    @MrGrigri

    I too am having this same issue. It appears to me that it needs to maintain the <base href="/"> tag instead of trying to inject the repository name. Maybe this could be accomplished in the angular-cli.json file in a `githubPages" object where you could customize the CNAME location and href value.

  2. jevenson commented on Jan 22, 2017

    @jevenson

    The CLI could check for the presence of a CNAME file in the repository, and when one is detected, do not modify the base tag.

    UPDATE:
    I'm looking at this file here, and it looks like there is an option. Trying to figure out how to use it at the moment.
    github-pages-deploy.run.ts

    SOLUTION:
    Using Beta 26, I found that running this command will resolve the issue:
    ng github-pages:deploy --custom-domain customdomain.com

    I'm not sure if there is a way to configure the custom domain in the angular-cli.json file, but if there isn't a way, there should be. Right now I have the above script in an npm script.

    Additionally, after updating to Beta 26 I had to remove my local gh-pages branch because it wasn't connected to the origin branch anymore for some reason.

  3. MrGrigri commented on Jan 23, 2017

    @MrGrigri

    I can confirm that it works with angular-cli version 1.0.0-beta.26. I still believe that there should be a better way. GitHub looks at the CNAME file, why can't the CLI?

  4. filipesilva commented on Jan 24, 2017

    @filipesilva
    Contributor

    Fixed by #3392. Sorry it wasn't well documented, we're going through the docs and fixing these gaps nowadays.

    @MrGrigri that PR actually creates the CNAME file. You might have one in your project, or you might not.

  5. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  6. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions