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

Fix flask backend mimetype for modules #1131

Merged
merged 4 commits into from
Oct 22, 2023

Conversation

elro444
Copy link
Contributor

@elro444 elro444 commented Aug 15, 2023

By submitting this pull request you agree that all contributions to this project are made under the MIT license.

Issues

When running reactpy with Flask backend, web.module_from_template resulted an error (in the browser) about wrong mimetype. In example:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.

Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: http://localhost:8000/_reactpy/modules/__from_template__/@material-ui/[email protected]

Solution

Explicitly add the mimetype when using send_file

Checklist

  • Tests have been included for all bug fixes or added functionality.
  • The changelog.rst has been updated with any significant changes.

@rmorshea
Copy link
Collaborator

I think we can do this, but is this possibly related to this sort of issue?

@elro444
Copy link
Contributor Author

elro444 commented Aug 16, 2023

Possibly, but doesn't seem to be exactly the same.
In any case, I just lookd at reactpy's implementation for the sanic backend, and saw that we do indeed pass there the text/javascript mimetype.

@elro444 elro444 force-pushed the fix-flask-backend-mimetype branch from 2e6255c to 552ea13 Compare August 16, 2023 10:31
@elro444
Copy link
Contributor Author

elro444 commented Aug 17, 2023

Umm, seems like the lint checks are broken?
Is it supposed to fail on files that i havened modified?

@rmorshea
Copy link
Collaborator

No. I'll put up a fix for that shortly.

@elro444
Copy link
Contributor Author

elro444 commented Sep 23, 2023

Hey @rmorshea any updates on this issue?

@rmorshea rmorshea merged commit 701e462 into reactive-python:main Oct 22, 2023
17 checks passed
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.

2 participants