enhance-dev / fastify-plugin

Build your Fastify app's views with custom elements. Powered by Enhance
https://enhance.dev/docs/learn/deployment/fastify
3 stars 0 forks source link

/_public routes and /enhance-styles.css respond with 404 #5

Closed sykesd closed 1 year ago

sykesd commented 1 year ago

I started with the Enhance quick start project. This works exactly as documented.

Following the Fastify docs, I then did the following in my quick start project:

The contents of index.mjs are:

import Fastify from 'fastify'
import Enhance from '@enhance/fastify-plugin'

const app = Fastify()

app.register(Enhance)

app.listen({ port: 3000 }, console.log)

When I launch this, the console shows:

null http://127.0.0.1:3000

When I visit http://localhost:3000 I see the expected content, but without styling or any images. When I check the developer tools I see that all requests for static content via /_public as well as the request for the CSS /enhance-styles.css all respond with 404.

This is on Windows 10 x64 on node 18.14.2.

I am assuming this is configuration, but I know so little about this that I don't know where to start.

NOTE: I am considering this for internal applications that would be running on internal infrastructure. Deploying to any cloud provider is not an option.

kristoferjoseph commented 1 year ago

Looks like static assets need to be configured.

The public folder needs to be mounted and the URLs to static assets would need to be updated.

https://github.com/fastify/fastify-static

kristoferjoseph commented 1 year ago

These instructions are how the plugin is meant to be used: https://enhance.dev/docs/learn/deployment/fastify

This plugin was designed to be used as such and not added to the enhance starter project.