Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refuse script src because MimeType is ('text/plain')? #42

Open
mihkuno opened this issue Dec 21, 2022 · 0 comments
Open

Refuse script src because MimeType is ('text/plain')? #42

mihkuno opened this issue Dec 21, 2022 · 0 comments

Comments

@mihkuno
Copy link

mihkuno commented Dec 21, 2022

What I intend to do:
I installed threejs from npm and then loading the local min script package to the html and it shows this error.

  • package gets loaded and is working fine on vscode live server and static html, but not on the webview widget in the flutter app

What the error is:

I/chromium( 9481): [INFO:CONSOLE(0)] "Refused to execute script from 'http://localhost:39875/node_modules/three/build/three.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.", source: http://localhost:39875/sketch.html (0)

Other things I did:

  • I tried 'imports', type="module", type="text/javascript", changing file structure with no luck and the same error is shown.

Temporary solution:

  • My work around for this at the moment is copying everything from the min script and pasting it inside the html script tag and it works as expected. But this makes my html file very large and inconvenient.

Here is a snippet of what I'm trying to do.

sketch.html

<!DOCTYPE html>
<head>
    <meta charset='utf-8' />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body></body>
<script src="./node_modules/three/build/three.min.js"></script>
</html>

sketch.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:webview_flutter_plus/webview_flutter_plus.dart';

class Sketch extends StatefulWidget {
  const Sketch({super.key});

  @override
  State<Sketch> createState() => _SketchState();
}

class _SketchState extends State<Sketch> {
  @override
  void initState() {
    if (Platform.isAndroid) {
      WebViewPlus.platform = SurfaceAndroidWebView();
    }
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return const WebViewPlus(
      initialUrl: 'sketch.html',
      javascriptMode: JavascriptMode.unrestricted,
    );
  }
}
@mihkuno mihkuno changed the title Refuse npm min script because MimeType is ('text/plain')? Refuse script src because MimeType is ('text/plain')? Dec 31, 2022
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

No branches or pull requests

1 participant