ara-framework / nova-proxy

Nova Proxy is a Server-Side Include Server to compose a page with micro-frontends views
MIT License
16 stars 4 forks source link

Inject client scripts URLs from Hypernova response #10

Open marconi1992 opened 4 years ago

marconi1992 commented 4 years ago

Stack Overflow Question: https://stackoverflow.com/questions/61478514/is-there-a-way-to-have-the-client-side-script-also-auto-loaded-from-the-proxy-cl#

We should be able to return the client script URLs in the Hypernova response and inject the corresponding script tags when including the Nova views.

Example.

{
    "success": true,
    "error": null,
    "results": {
        "example": {
            "name": "Example",
            "html": "<div data-hypernova-key=\"Example\" data-hypernova-id=\"33719ec2-1b19-4023-8b2b-e82aa29990cc\"><h1 data-server-rendered=\"true\">Ara Framework</h1></div>\n<script type=\"application/json\" data-hypernova-key=\"Example\" data-hypernova-id=\"33719ec2-1b19-4023-8b2b-e82aa29990cc\"><!--{\"title\":\"Ara Framework\"}--></script>",
            "meta": {
                "src": "http://localhost:3000/public/client.js"
            },
            "duration": 0.36806,
            "statusCode": 200,
            "success": true,
            "error": null
        }
    }
}

Nova Proxy should include the next HTML element in the host page:

<script async src="http://localhost:3000/public/client.js" >
windagency commented 3 years ago

Hi @marconi1992 As mentioned in https://stackoverflow.com/q/64943789/14681547, I'm experiencing an issue which seems to be related to this answer

It therefore always seems compulsory to declare client.js scripts even if they are declared in the Nova Proxy. Is it this ? Yet it seemed to me to understand that the PR from April could resolve it but is actually blocked ... so waiting for this ;)