Skip to content

chore (frontend): return 404 instead of index.html on requests for non existing assets - #240

Merged
zheli merged 4 commits into
bitdynamics-ab:mainfrom
elfedy:elfedy-fix-stale-frontend
Jul 15, 2026
Merged

chore (frontend): return 404 instead of index.html on requests for non existing assets#240
zheli merged 4 commits into
bitdynamics-ab:mainfrom
elfedy:elfedy-fix-stale-frontend

Conversation

@elfedy

@elfedy elfedy commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Current index.html references an outdated asset file. On the browser, the error returned was:

 index-Dih_DGnJ.js:1 Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.` 

The error makes debugging confusing as the real reason for the failure is that the asset file does not exist. Returning a resource that is not the one requested is also non REST-like behavior and should be avoided when possible.

This PR updates the outdated reference and adds:

  • Returning a 404 error when looking for a file in the assets directory.
  • A TestFrontend_DistIndexReferencesExistingAssets test to make sure the index does not reference non existing assets

@srikanth-bitdynamics

Copy link
Copy Markdown
Collaborator

Thanks for chasing this down — the MIME type "text/html" diagnosis is spot on, and the /assets/* → 404 change plus the tests are good.

One blocker: the hash bump doesn't fix the root cause, and it's why CI is red.

dist/assets/ is gitignored — only the placeholder index.html is tracked (.gitignore + the assets.go doc comment). So a committed real index.html always references assets that aren't in git; swapping one hash for another just moves the dangling reference. CI never runs npm run build (ci.yml), so TestFrontend_DistIndexReferencesExistingAssets runs against a dist/ with no assets/ and fails on all three refs.

@zheli

zheli commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@elfedy Thanks for your contribution.

We have fixed the regression in an earlier PR and you can find it here:
https://github.com/bitdynamics-ab/canton-devkit/pull/241/changes#diff-a3034210ddc9d7e50790c5d3007372044fde9dd7bc0a54bacf1bb3b2845aa89c

I also added a nicer instruction for testing or running UI in dev environment: #255. Plesae check if that helps! I will be happy to approve this PR once the conflicts are fixed.

@elfedy

elfedy commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@srikanth-bitdynamics @zheli thanks for the comments, makes sense. Removed the regression fix attempt and kept the 404 behavior when serving assets. Will also rename the PR to better reflect the change.

@elfedy elfedy changed the title fix (frontend): update artifact references in index.html chore (frontend): return 404 instead of index.html on requests for non existing assets Jul 13, 2026
@zheli
zheli merged commit aa06629 into bitdynamics-ab:main Jul 15, 2026
@zheli

zheli commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Merged. Thank you for your contribution @elfedy !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants