<p>Using the component as part of a Spin application Let’s have a look at the component definition (from spin.toml):</p> <pre><code class="language-toml">[[component]] source = &quot;spin_static_fs.wasm&quot; id = &quot;fileserver&quot; files = [{ source = &quot;&quot;, destination = &quot;/&quot; }] [component.trigger] route = &quot;/...&quot; </code></pre> <p>This component will recursively mount all files from the current directory and will serve them. If an index.html file is in the source root, it will be served if no file is specified.</p> <p>Running the static server:</p> <pre><code>$ spin up --listen 127.0.0.1:3000 --file spin.toml At this point, the component is going to serve all files in the current directory, and this can be tested using curl: $ curl localhost:3000/LICENSE Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION ... </code></pre> <p><em>Setting the cache header</em> Currently, this file server has a single cache header that it can set through the CACHE_CONTROL environment variable. If no value is set, the default max-age=60 is used instead for all media types.</p> <p><em>Setting the fallback path</em> You can configure a FALLBACK_PATH environment variable that points to a file that will be returned instead of the default 404 Not Found response. If no environment value is set, the default behavior is to return a 404 Not Found response. This behavior is useful for Single Page Applications that use view routers on the front-end like React and Vue.</p> <p><em>For more on configuring a component, see: https://spin.fermyon.dev/configuration/</em> [[component]] source = “target/wasm32-wasi/release/spin_static_fs.wasm” id = “fs” files = [{ source = “test”, destination = “/” }] environment = { FALLBACK_PATH = “index.html” }</p>