denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.53k stars 648 forks source link

imported revive function and islands from script into browser is not taking basepath into account #2326

Closed Bramart closed 8 months ago

Bramart commented 8 months ago

Trying to add a basepath /neoplayer/ to a deno fresh app, with another app (node project) at the root. Basepath is setup in deno fresh config and import in main.ts. Everything works fine except the islands.

In the html file loaded in the browser, basepath is applied to src and href (like said in the docs)

image

At the end there is a script that imports the revive function from main.js and islands from their own js files. Those imports are not prefixed with the basepath.

image

So the request is on the root and the js is not load which leads me to this error in the browser because my root application returns a 404 error page :

image

deno version : 1.36.1 deno fresh version : 1.6.5

deer commented 8 months ago

Hi @Bramart, I coded this feature. There is a test for it here: https://github.com/denoland/fresh/blob/46eaef0181cba60a5e0284f58b24925e762c7784/tests/base_path_test.ts#L130 which uses: https://github.com/denoland/fresh/blob/46eaef0181cba60a5e0284f58b24925e762c7784/tests/fixture_base_path/routes/islands.tsx#L4

Can you provide some more details? They should all be redirected like this:

Screen Shot 2024-02-20 at 15 30 33

I'll need more information (ideally a repository which easily reproduces the problem) in order to proceed, because from my side it's working. I guess the test is missing something though.

Bramart commented 8 months ago

Hi, here is a fresh repo I just create and still facing the same issue with : https://github.com/Bramart/fresh-project (deno fresh example with basepath config ...)

In local, it works for me too, they are redirected (I have interactivity) :

Capture d’écran du 2024-02-20 17-45-31

But once deployed behind another app, they are not (and no interactivity) :

Capture d’écran du 2024-02-20 17-44-44 Capture d’écran du 2024-02-20 17-44-58

In local, the redirection is made by fresh because fresh manage the whole app, but once deployed to a basepath and next to another app, those requests just hit on the root application like they are supposed to, no ?

deer commented 8 months ago

You are very right there. I have a fix and I'm working on a test. Oops 😅