podium-lib / issues

All podium issues, bugs, questions etc goes here. Documentation is to be found at https://podium-lib.io
1 stars 0 forks source link

how to wrap an existing web app into podlet #45

Open idavollen opened 3 years ago

idavollen commented 3 years ago

given that we have an existing, stand alone web app containing ajax calls, no matter whether it is written in React, Angular, jQuery or jsp, how easily can I wrap it inside of a Podlet such that all URLs for assets, form-post, ajax calls from the original web page still works fine with the container/lay-out compound web app? BTW, we don't want to make the original web app public accessible afterwards.

should I have to intercept the app.get(podlet.content() as following?

    app.get(podlet.content(), async (req, res) => {
    let response = await fetch(url_for_original_web_app)
    const { mountOrigin, mountPathname } = res.locals.podium.context;
    const podium_url = new URL(mountPathname, mountOrigin);
    let new_res = response.replace(url_for_original_web_app, podium_url)
    res.status(200).podiumSend(new_res);
});

What is the suggested best practices?

digitalsadhu commented 2 years ago

Not a case we've worked with but if you don't plan on touching the original web app then doing something like you suggest seems like the only option.

You might have to do something like response.content.replaceAll rather than response.replace I'd guess but the approach should work.

Our usual approach would be to migrate the existing app's client side code into the podlet itself.

mingfang commented 2 years ago

This is a very important use case for me. I need to integrate with third party applications.

hunt3r commented 8 months ago

I honestly thought this was the purpose of this library. Has anyone been able to achieve this? I'm trying to setup a strangler-fig style migration path for a client and I was hoping I could use this to proxy the contents of the old and new app (frameless) into a single app shell owned by podium, it would need to support glob paths though too? I don't see a way to support /* paths to the podlet? Do I have to enumerate every path in the server wire up?

Curious if anyone uses this library like this.

digitalsadhu commented 6 months ago

Not sure if you can make this work but you could try writing and serving a manifest.json file for your 3rd party application and pointing your layout at this. In this manifest file, you could define the url to the 3rd party app and include its client side CSS and JS assets so that the layout knows about them. Any chance this approach might work?