exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework
https://ultrajs.dev
MIT License
2.99k stars 66 forks source link

Fails to load dynamic routes when opened directly (opening from the address bar, not redirecting to it via code) #213

Closed rojvv closed 1 year ago

rojvv commented 1 year ago

This is most probably related to the import maps.

rojvv commented 1 year ago

image

rojvv commented 1 year ago

image

rojvv commented 1 year ago

TL;DR

A dynamic route is at /foo/bar, and the import map entries like ./vendor/... and ./src/... lead to /foo/vendor/... and /foo/src/... which will then be 404, hence return text/html, and not the wanted script.

I could only reproduce this in production build.

deckchairlabs commented 1 year ago

This is fixed in v2.1.3

rojvv commented 1 year ago

@deckchairlabs Seems like the location is now fixed, but it is trying to load .tsx instead of the production .js. Should we reopen this? :)

deckchairlabs commented 1 year ago

Hi @roj1512 , could you post the generated importMaps?

rojvv commented 1 year ago

Browser

image

rojvv commented 1 year ago

The error

Uncaught (in promise) Error: Unsupported Content-Type "text/html; charset=utf-8" loading https://host:port/src/app.tsx imported from https://host:port/client.b3e5c79f.js. Modules must be served with a valid MIME type like application/javascript.
rojvv commented 1 year ago

image

deckchairlabs commented 1 year ago

Ah interesting, so its when linking to a path with more than one segment in the pathname eg https://example.com/blog/post-1

Could you try putting <base href="/" /> in the <head> element and see if that solves it?

rojvv commented 1 year ago

Yes, that <base href="/" /> fixes it.