When deploying a Function, you can specify an assets directory using the
-p flag. This directory will be served by Lagon at the root of your Function's URL.
Automatic assets serving
Let's say you have a Function inside an
index.ts file, with a favicon and an image:
index.ts public/ favicon.ico images/ image.png
To deploy this Function with these assets, you can use the
lagon deploy ./index.ts --public public # Same as lagon deploy ./index.ts -p public
Your Function is now deployed to
example.lagon.dev. You can access the favicon and the image at the following URLs:
In your HTML, you can reference these files using relative paths:
<link rel="icon" href="/favicon.ico" /> <!-- ... --> <img src="/images/image.png" />
The number of assets per Deployment is limited to 100 for Personal plans, and 1000 for Pro plans. The size of each asset is also limited to prevent abuses. Learn more about the assets limits.