The problem: Whenever I try to make a request to a Laravel API hosted with Laravel Vapor, I get a 502. When I view error logs in Cloudwatch, I see this:
As you can see here, the 502 is being returned because there seems either to be a permissions problem with the bootstrap/cache folder or the folder is not present for some reason after deployment.
What I did to try to fix this:
All of the above did not yield any results and the support team tried their best but also could not identify the issue.
The solution?? So, one of my teammates noticed that we only started experiencing this issue after adding the vapor-ui package. I removed it completely from our projects, redeployed, and no more error. The API responds as expected now.
My question is, why would installing vapor-ui cause this issue? I know that the vapor-ui project itself is a Laravel project so could it be that there is no bootstrap/cache folder in the vapor-ui project?
Here are snippets of my vapor.yml file before removing the vapor-ui:
id: 1234
name: notreal
environments:
production:
domain: notreal.notreal.com
memory: 1024
cli-memory: 512
runtime: docker
network: vapor-network-123
build:
- 'composer install --no-dev'
- 'php artisan vapor-ui:install'
- 'npm ci && npm run prod && rm -rf node_modules'
staging:
domain: sta-notreal.notreal.com
memory: 1024
cli-memory: 512
runtime: docker
network: vapor-network-1647335449
database: notreal-sta
build:
- 'composer install'
- 'php artisan vapor-ui:install'
- 'npm ci && npm run dev && rm -rf node_modules'
development:
domain: dev-notreal.notreal.com
memory: 1024
cli-memory: 512
runtime: docker
network: vapor-network-123
database: notreal-dev
build:
- 'composer install'
- 'php artisan vapor-ui:install'
- 'npm ci && npm run prod && rm -rf node_modules'
I don't think you need this build step: php artisan vapor-ui:install
You do it locally and then everything is in place already when you deploy