Error with MIME, I've recently setup a rule to set .js files to be treated as .js files.

Error with MIME, I've recently setup a rule to set .js files to be treated as .js files. yet, I still get an error saying this: here's my rules.
No description
No description
Solution:
so your html should be like this: Before: <link rel="stylesheet" href="styles.css"> specifying just a file name makes it relative to the current dir, so it tries to load it at /auth/style.css if you're on that page to...
Jump to solution
28 Replies
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
No description
Chaika
Chaika4mo ago
Wildcard isn't regex, it's much simpler then that: https://developers.cloudflare.com/ruleset-engine/rules-language/operators/#wildcard-matching Also your expression is literally URI Full Wildcard "http request uri matches ..." doesn't make sense URI Path Ends With is a lot simpler and better
Cloudflare Docs
Operators and grouping symbols
Learn about comparison, logical operators, and grouping symbols in Cloudflare's Rules language. Understand precedence and how to structure expressions.
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
OH IM STUPID
Chaika
Chaika4mo ago
but also, what are you trying to do? https://flyier.xyz/auth/login.js legitimately does not return JS, neither does https://flyier.xyz/auth/styles.css return CSS. You can override the mime type all you want but it's not going to do anything
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
i went off a template and forgot to update it XD
Chaika
Chaika4mo ago
You still really shouldn't need to override mime type/your origin should set it automatically if it was actually returning JS and css, which it's not
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
I'm not sure why it doesn't exist in the /auth/ because it exists on https://flyier.xyz in the network tab. I guess my question is how do I make it return as css and js? because in my github repo
Chaika
Chaika4mo ago
Depends on your origin/web server setup Are you using Github Pages, Cloudflare Pages, Workers Static assets, or something else?
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
github pages
No description
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
i'm gonna assume that's why.
Chaika
Chaika4mo ago
it's just missing those files in the deploy step yea. Not sure if you're using a framework to build but there's def no login.js there
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
No description
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
its under the auth/callback
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
so then why isn't it running here if it does exist
Chaika
Chaika4mo ago
you're not fetching it from that directory you're trying to load it from https://flyier.xyz/auth/login.js missing /callback/
Chaika
Chaika4mo ago
and you're trying to load https://flyier.xyz/auth/styles.css but it's not at /auth/style.css it's at the root https://flyier.xyz/styles.css
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
there's 2 seperate css files one for the homepage styles.css and one for the callback
Chaika
Chaika4mo ago
auth-callback.css?
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
yeah
Solution
Chaika
Chaika4mo ago
so your html should be like this: Before: <link rel="stylesheet" href="styles.css"> specifying just a file name makes it relative to the current dir, so it tries to load it at /auth/style.css if you're on that page to <link rel="stylesheet" href="/auth/callback/auth-callback.css"> starting with / makes it all relative to the root of the site instead of the current directory old: <script src="login.js"></script> new: <script src="/auth/callback/login.js"></script>
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
so this: <link rel="stylesheet" href="/auth/callback/auth-callback.css"> <script src="/auth/callback/login.js"></script>?
Chaika
Chaika4mo ago
yes
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
perfect tysm! so it wasn't with MIME after all...
Chaika
Chaika4mo ago
Because your files couldn't be found it was serving a default page (your index.html) which is of course, HTML and not CSS/JS so the Browser was just like "hey this is attempting to load it as CSS/JS but this is clearly not right" MIME Types are essentially file extensions in the web world, like trying to load a word doc .docx as a png by renaming it, just not going to work lol
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
pushing to origin rn ill keep you posted ah so so I was telling it nvm you said it beautifully XD
<pixel_kotlin>
<pixel_kotlin>OP4mo ago
fr man tho @Chaika tysm i'm completely new to this so its really helpful

Did you find this page helpful?