Disallowed MIME type (“text/html”)

I am using live server extension on vs code. I have failed to import from another file within the same directory. I have config.js where I keep my API key so that I .gitignore it to avoid pushing it to gitHub . I need to import the API key to index.js where I use it. I keep getting this annoying error.

Loading module from “http://127.0.0.1:5500/src/config” was blocked because of a disallowed MIME type (“text/html”).

Is there a way to fix this so that I continue using live server?