Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed open in tab by using HTML docs baseURI so the deployed path is included in links. #80

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

sei-mpriest
Copy link
Contributor

Fixed this using the HTML doc's baseURI in the window.open links. I tried to find an idiomatic way to do this via the Angular router, but that did not seem to work. I believe that a routerLink directive would correctly take the base href setting in index.html into account, but it does not seem to when doing a call via ts code. For example, this code did not work:

  const urlTree = this.router.createUrlTree([
              '/exhibit',
              this.exhibit.id,
              'article',
              userArticle.articleId,
            ]);
  const url = this.router.serializeUrl(urlTree); 
  window.open(url);

My actual fix was borrowed from @sei-aschlackman:

  const url =
              document.baseURI +
              '/exhibit/' +
              this.exhibit.id +
              '/article/' +
              userArticle.articleId;
  window.open(url);

I tested this by changing my index.html to include

<base href="/myapp/">

I ran ng serve with the --serve-path argument to get it to serve at that path as well

ng serve  --serve-path /myapp/

@sei-mpriest sei-mpriest merged commit 2556a4e into development Aug 12, 2024
2 checks passed
@sei-mpriest sei-mpriest deleted the cwdoe-1364-new-tab-fix branch August 12, 2024 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants