Heroku 403 Forbidden for static js files
Asked Answered
M

3

8

I have push my simple php app to Heroku and get 403 status for some js files.

https://guarded-forest-7267.herokuapp.com/vendor/jquery/dist/jquery.min.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jquery-form/jquery.form.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jquery-validate/dist/jquery.validate.min.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jquery.inputmask/dist/inputmask/jquery.inputmask.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/modernizer/modernizr.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jselector/src/jquery.jselector.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/rubber-carousel/dist/jquery.rubber-carousel.min.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jmodal/src/jquery.jmodal.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/scrollReveal.js/dist/scrollReveal.min.js Failed to load resource: the server responded with a status of 403 (Forbidden)

Whats the problem can be?

Megavolt answered 23/2, 2015 at 21:51 Comment(1)
does anybody know the answer? m facing the same issueRoderic
W
2

I was facing the same issue. It is because you are trying to access files inside the vendor directory. Static files inside the ‘vendor’ folder cannot be accessed due to some heroku permission issues.

I moved the files to a new directory named 'js', and re-deployed the app. Works fine now.

Wirewove answered 26/5, 2020 at 11:47 Comment(0)
W
1

Make sure your static directories do not have reserved word in Heroku such as vendor and bin To get more information see devcenter.heroku.com/articles/deploying-php

Wunderlich answered 2/10, 2019 at 14:18 Comment(2)
Thanks for your answer. In my case, I renamed the vendor directory to something else and static files served flawlessly.Pipe
I am glad that it helpsWunderlich
R
0

It was due to misconfiguration in .htaccess file

If there are any RewriteRule in your .htaccess file add these RewriteCond before it.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

For example this code allow you to redirect all requests except static files to index.php

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php
Royroyal answered 3/4, 2015 at 12:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.