schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs, SSR and SSG.
https://jasprpad.schultek.de
MIT License
1.23k stars 76 forks source link

fix: SSR app does not work on Mac Safari - but works on Chrome #186

Closed walsha2 closed 6 months ago

walsha2 commented 6 months ago

Chrome

Run any basic SSR app as normal and compare the instance opened on Chrome and on Safari. I keep seeing this console message in the Chrome browser:

Refused to execute script from 'http://localhost:4322/main.dart.js' because its 
MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

However, everything seems to work fine on Chrome. The server/client side code work as expected.

Safari MacOS

With the app still running, open in a Safari browser on MacOS. Things are more catastrophic here and the server actually responds with a 500 (Internal Server Error).

The Content-Type warning may be a clue as to why this may be happening and why the server error only happens on Safari.

Browser Console

[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (app.client.dart.bootstrap.js, line 0)
[Error] Refused to execute http://localhost:8080/@http://localhost:8080/components/app.client.dart.bootstrap.js as script because "X-Content-Type-Options: nosniff" was given and its Content-Type is not a script MIME type.
[Error] Error: Script error for "app.client.dart.bootstrap"
http://requirejs.org/docs/errors.html#scripterror
    defaultOnError (require.js:143)
    onError (require.js:549)
    onScriptError (require.js:1738)

Jaspr Server

[SERVER] [ERROR] GET /@http://localhost:8080/components/app.client.dart.bootstrap.js
[SERVER] [ERROR] Error thrown by handler.
[SERVER] [ERROR] FormatException: Scheme not starting with alphabetic character (at character 1)
[SERVER] [ERROR] @http://localhost:8080/components/app.client.dart.bootstrap.js
[SERVER] [ERROR] ^
[SERVER] [ERROR] dart:core                                           _SimpleUri.resolve
[SERVER] [ERROR] package:shelf_proxy/shelf_proxy.dart 42:28          proxyHandler.<fn>
[SERVER] [ERROR] package:jaspr/src/server/server_handler.dart 74:32  _proxyHandler.<fn>

Reproduce

Steps To Reproduce

jaspr create (basic)
jaspr serve

Doctor Output

[✓] Jaspr CLI (Version 0.10.0)
  • Dart Version 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "macos_arm64"
  • Running on macos Version 14.4 (Build 23E214) - Locale en-US
  • Analytics: Enabled

[✓] Current Project
  • Dependencies on core packages:
    • jaspr: ^0.10.0 (git -> main)
    • jaspr_builder: ^0.10.0 (git -> main)
    • jaspr_riverpod: ^0.3.9
    • jaspr_router: ^0.3.1
  • Uses server-side rendering: true
  • Uses experimental compilers: false
  • Uses flutter embedding: false
schultek commented 6 months ago

Looks like a duplicate of #58

walsha2 commented 6 months ago

Looks like a duplicate of #58

Yea I think so. We can close this issue in favor of that.