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

How can i change baseHref, need for Single page app #2334

Closed
ietabhi opened this issue May 15, 2024 · 5 comments
Closed

How can i change baseHref, need for Single page app #2334

ietabhi opened this issue May 15, 2024 · 5 comments
Assignees
Labels
Solved user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running

Comments

@ietabhi
Copy link

ietabhi commented May 15, 2024

I need your help!
How can i change baseHref instead of directly reading from browser?

Describe the bug

I am looking to update baseHref so that i can point child app pdfjs file?
For SPA parent app domain is getting picked and baseHref not allowing to set public path for js files

Version info

  • latest

Demo PDF file
NA

@stephanrauh
Copy link
Owner

stephanrauh commented May 25, 2024

Sorry for answering late - I've missed your ticket during my vacations. I'm afraid I don't understand what you're trying to do. Are you looking for pdfDefaultOptions.assetsFolder?

https://pdfviewer.net/extended-pdf-viewer/options
A live demo of using a different assets folder is here: https://pdfviewer.net/extended-pdf-viewer/pdfjs-versions (although it seems to be broken at the moment - but the code snippets on the page are still valid).

@stephanrauh stephanrauh self-assigned this May 25, 2024
@stephanrauh stephanrauh added waiting for the user's answer user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running labels May 25, 2024
@ietabhi
Copy link
Author

ietabhi commented May 27, 2024

as part of SPA we need to pass /mfes/ from child add, as this is called from parent App,

currently we are updating basehref with this code and no way i can update same.

this.baseHref = this.platformLocation.getBaseHrefFromDOM();

exp : https://abc.xyz.com/portal
Child App URL : https://abc.xyz.com/childApp

If i want to use Child app assets inside parent app i need to pass assets like below exp :

https://abc.xyz.com/mfes/childApp/assets/images/1.png

so for SPA if you can allow me to override this value it will be really helpful

@stephanrauh
Copy link
Owner

This sounds like you're looking for pdfDefaultOptions.assetsFolder. Modifying this property allows you to use an arbitrary folder instead of the default assets folder.

@ietabhi
Copy link
Author

ietabhi commented May 28, 2024

This is not just updating assetsFolder as basehref will be always taken by below code

this.baseHref = this.platformLocation.getBaseHrefFromDOM();

so if i have app running with https://abc.xyz.com/123ismybasehref/home.html

and i change assets folder by pdfDefaultOptions.assetsFolder = newassets/images

default path for images will change to /123ismybasehref/newassets/images

for SPA apps we need to access assets from /mfes/123ismybasehref/newassets/images

So there is no way to add /mfes before basehref currently as it will always take from browser url.

This is important change needs to be added for all SPA apps.

@stephanrauh
Copy link
Owner

Can you send me a reproducuer, please?

This is important change needs to be added for all SPA apps.

Please elaborate. Every application written in React, Vue.js or Angular is an SPA app. Why do you think changing my library improves any application written in React.js or Vue.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Solved user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running
Projects
None yet
Development

No branches or pull requests

2 participants