question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot disable <base /> tag in web application

See original GitHub issue

Hi!

I’m not entirely sure if this should be a feature request, but going of what I read in the source I suspect the intended behaviour is different that what it’s currently doing.

Current Behavior

When building/compiling a web application, the <base /> tag is always added to the <head /> of the index.html file. In our case this gets in the way and we want to turn it of completely.

Expected Behavior

Passing null or an empty string to the baseHref option to disable the <base /> tag.

Steps to Reproduce

  1. Generate a web app in a workspace
  2. Pass null or an empty string to the baseHref option of the build/serve target of the application in workspace.json
  3. build/serve the application

When passing null, building/compiling fails altogether, when passing an empty string a <base href="(unknown)" /> is injected.

The augment-index-html utility seems to (try to) accomodate for excluding a <base /> tag going of this comment. But the condition checks for typeof params.baseHref == 'string', and the schema of the build, and serve builder require this to be a string and provides a default value of /. Thus, the <base /> tag is always added.

To fix this, it seems you can either

  • allow null to be passed by changing the schema of the builder(s), or
  • also check if params.baseHref is not an empty string.

I’m willing so submit a PR but I don’t know if there is a preference for one of the options.

Environment

NX version 11.5.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rokkiecommented, Mar 22, 2021

By overriding the webpack config and setting the publicPath.

0reactions
github-actions[bot]commented, Sep 27, 2021

This issue has been automatically marked as stale because it hasn’t had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable the base href for just one link - Stack Overflow
I have a website, which uses base href ...
Read more >
PM09156: DISABLE HTML BASE TAG USAGE - IBM
Due to these issues, this APAR switches off the usage of the HTML base tag per default by setting the following configuration on...
Read more >
HTML attribute: disabled - HTML: HyperText Markup Language
This Boolean disabled attribute indicates that the user cannot interact with the control or its descendant controls.
Read more >
HTML select disabled Attribute - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >
Docs • Svelte
With this, npm run build will generate HTML, JS and CSS files inside the ... A <script> block contains JavaScript that runs when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found