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

bug: MIME Types ignored/blocked in strict mode #5793

Closed
CrystalLake87 opened this issue Jul 26, 2022 · 8 comments · Fixed by #5853
Closed

bug: MIME Types ignored/blocked in strict mode #5793

CrystalLake87 opened this issue Jul 26, 2022 · 8 comments · Fixed by #5853
Labels
needs reproduction needs reproducible example to illustrate the issue platform: ios

Comments

@CrystalLake87
Copy link

Bug Report

Platform(s)

iOS (14.0+)

Current Behavior

XCode / iOS Simulator is not loading local stylesheets when running on brand new MacBook with M1 Pro - page loads but local CSS files do not load. Safari Inspector shows error messages related to the MIME types of the specified stylesheets, even when type="text/css" is specified in the tags. XCode is NOT running in Rosetta mode as suggested in previous bug reports.

Safari Error Message:
"Did not parse stylesheet at 'capacitor://{app_name}/{file_name}.css' because non CSS MIME types are not allowed in strict mode."

Expected Behavior

Specified stylesheets should load without error and be applied properly.

@jcesarmobile jcesarmobile added the needs reproduction needs reproducible example to illustrate the issue label Jul 27, 2022
@Ionitron
Copy link
Collaborator

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks!
Ionitron 💙

@Ionitron Ionitron added the needs reply needs reply from the user label Jul 27, 2022
@CrystalLake87
Copy link
Author

CrystalLake87 commented Jul 27, 2022

Issue can be reproduced using the standard capacitor test app at:
https://github.com/ionic-team/capacitor-testapp.git

Environment:
MacBook Pro (2021) with M1 Pro
MacOS Monterrey 12.3
Xcode version 13.4.1

Steps to reproduce:

From MacOS running on M1 or M1 Pro, clone repo:

Console gives following output:

[Error] Did not parse stylesheet at 'capacitor://localhost/static/css/7.532f36fa.chunk.css' because non CSS MIME types are not allowed in strict mode.
[Error] Did not parse stylesheet at 'capacitor://localhost/static/css/main.fc34ace5.chunk.css' because non CSS MIME types are not allowed in strict mode.

@Ionitron Ionitron removed the needs reply needs reply from the user label Jul 27, 2022
@CrystalLake87
Copy link
Author

Inspecting the Network requests for these files shows they were served with MIME Type "application/octet-stream":

Summary
URL: capacitor://localhost/static/css/7.532f36fa.chunk.css
Status: 200
Source: —
Initiator:
home:1

Request
Accept: text/css,/;q=0.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko)

Response
Cache-Control: no-cache
Content-Type: application/octet-stream

@christinaasu
Copy link

+1 just got an M1 Mac and now facing this issue with all of my projects. Not running Xcode in Rosetta either.

@CrystalLake87
Copy link
Author

@jcesarmobile Have you guys been able to look into this? Even after updating Capacitor to the latest version (4.0.1), CSS files still aren't loading as expected

@notcaring42
Copy link

I know this repo is for Capacitor, but I can confirm this occurs in Cordova as well. I was able to get around this issue (temporarily) by adding this code to IONAssetHandler.m, in the function getMimeType:

if ([fileExtension isEqualToString:@"css"]) {
      return @"text/css";
}

I have only seen this when running in Rosetta, but I can't run on the M1 chip directly because of some of the plugins I am using. So I have not been able to confirm myself if this is Rosetta-only.

@adamkpurdy
Copy link

Same experience here. Cloned the repo for the standard test app.
Environment:
MacBook Pro (2021) with M1 Max
MacOS Monterrey 12.5
Xcode version 13.4.1

Screen Shot 2022-08-10 at 7 24 31 PM

Screen Shot 2022-08-10 at 7 25 38 PM

tony-scio pushed a commit to tony-scio/capacitor that referenced this issue Aug 18, 2022
…5853)

* Fixed issue ionic-team#5793

* add TODO

* fmt

* Disable type_body_length rule

Accommodating the big MIME list

Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
Co-authored-by: giralte-ionic <97970732+giralte-ionic@users.noreply.github.com>
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs reproduction needs reproducible example to illustrate the issue platform: ios
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants