Reputation: 4675
I've got a GAE application with a directory called static with two sub-directories css and js. Each of these directories have CSS and JavaScript files respectively. In my HTML code I've got references to these files such as:
<script src="/static/js/bootstrap-typeahead.js"></script>
And my app.yaml file looks like this:
application: ********
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /static
static_dir: static
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /.*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
However, the CSS styles and JavaScript files aren't applied to the HTML code and when I view source and click on the links in the code, the CSS and JS files open up in a new tab and a download prompt pops up.
Q: Why are these files being downloaded instead of being linked with my HTML?
EDIT: I'm not sure if this is relevant but my GAE logs reveal that the request is returned with a 304 response:
INFO 2015-02-05 18:43:51,229 module.py:639] default: "GET /static/js/bootstrap-typeahead.js HTTP/1.1" 304 -
EDIT 2: Looking at my Google Chrome developer tools' network tab I came to know that the mime type for these files is application/x-js and application/x-css. Now, I'm certain that this is the cause of my problems but why is the mime type so when the docs clearly mention that,
By default, App Engine serves static files using a MIME type based on the filename extension. For example, a file with a name ending in .css will be served with a MIME type of text/css.
I tried modifying the mime type through app.yaml by explicitly specifying the mime types but it still doesn't change.
Upvotes: 2
Views: 530
Reputation: 154
I had the same problem and I resolved to clean the staging bucket.
For do this, I open bucket section on my GCP console and you remove all file in the bucket with name staging.{projectname}.appspot.com
Upvotes: 1