Vapor: Serving Assets From The Root Domain

Vapor: Serving Assets From The Root Domain

As you may know, during deployment Vapor automatically extracts all of the assets in your Laravel project's public directory and uploads them to S3. Also, Vapor creates an AWS CloudFront (CDN) distribution to distribute these assets efficiently around the world.

As convenient as that may be, some applications like PWAs may need to serve certain assets from the root domain. For example, JavaScript service workers must be served from the same origin as the referrer.

Starting today, you can now serve specific assets from the root domain. To get started, just head over to your application's config/vapor.php file, and add an array of assets that should be served in your root domain:

At the time of this writing, and due to the serverless nature of applications powered by Vapor, assets served from the root domain are not cacheable at the client-side and they are served using Laravel routes. Therefore, you should only serve assets that absolutely must be served from the root domain as there is a slight performance penalty for doing so.

In addition to this new feature, you can now instruct Vapor to interpret the public directory's dot files as assets. For that, you just have to set the dot-files-as-assets key to true in your vapor.yml file:

And, of course, you can opt to serve those dot files from the root domain as well:

Finally, keep in mind that those features are only available on the latest versions of vapor-cli, and vapor-core packages. Enjoy!

Keep reading

ProductMar 2, 2026

Laravel February Product Updates

Laravel Cloud API & CLI, MySQL 8.4 upgrade notice, Forge MySQL 9, Nightwatch MCP & Linear integration, and new Framework AI updates.

Laravel Team

ProductFeb 3, 2026

Laravel January Product Releases

January brings Private Cloud, Valkey caching, expanded Cloud API, plus Forge backup options and Nightwatch real-time exception detection.

Laravel Team