Set my JS MIME type to “text/javascript”

后端 未结 2 1113
滥情空心
滥情空心 2021-02-19 21:52

According to this: Javascript MIME Type, it seems that I should be serving my JS as \"text/javascript\". When I inspect the network communication between my browser and localhos

相关标签:
2条回答
  • 2021-02-19 22:50

    The AddType directive should be sufficient enough unless there's something that's forcing the type, but you can also try:

    <Files "*.js">
        ForceType text/javascript
    </Files>
    

    A better solution may be to look through your vhost/server config and all of the apache config files (that may be included by default in your config) for instances of application/x-javascript to see how that's being set. It may be better to just change it there instead of htaccess file, which may not have the neccessary override options (mod_mime's AddType and ForceType, for example, require the FileInfo AllowOverride option).

    0 讨论(0)
  • 2021-02-19 22:51

    you need to change your settings in mimes.types file found in your apache conf folder. Change

    application/javascript          js
    

    to

    text/javascript                 js
    

    and restart apache, you should see the change

    0 讨论(0)
提交回复
热议问题