emersonthis emersonthis - 2 months ago 18
Javascript Question

403 error for js files in vendor directory on Heroku

My CakePHP v3.x app runs fine in my local Vagrant environment, but when I deploy to Heroku, I get 403 errors for all javascript files located in

/webroot/vendor/...


CSS and javascript files outside that directory load fine.

https://example.com/js/i_load_fine.js
https://example.com/vendor/i_cause_403_error.js


/Procfile

web: vendor/bin/heroku-php-apache2


This question sounds similar, but I checked and .htaccess already has the recommended RewriteCond:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Answer

Turns out that I had to specify the document root as a second parameter in the Procfile: web: vendor/bin/heroku-php-apache2 webroot/

Comments