Skip to content

Fix flask backend mimetype for modules - #1131

Merged
rmorshea merged 4 commits into
reactive-python:mainfrom
elro444:fix-flask-backend-mimetype
Oct 22, 2023
Merged

Fix flask backend mimetype for modules#1131
rmorshea merged 4 commits into
reactive-python:mainfrom
elro444:fix-flask-backend-mimetype

Conversation

@elro444

@elro444elro444 commented Aug 15, 2023

Copy link
Copy Markdown
Contributor

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/core@4.12.4.4.js

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
Copy Markdown
Collaborator

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

@elro444

Copy link
Copy Markdown
ContributorAuthor

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
elro444force-pushed the fix-flask-backend-mimetype branch from 2e6255c to 552ea13CompareAugust 16, 2023 10:31
@elro444

Copy link
Copy Markdown
ContributorAuthor

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

@rmorshea

Copy link
Copy Markdown
Collaborator

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

@elro444

Copy link
Copy Markdown
ContributorAuthor

Hey @rmorshea any updates on this issue?

@rmorshea
rmorshea merged commit 701e462 into reactive-python:mainOct 22, 2023
Sign up for freeto 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

@elro444@rmorshea