Skip to content

Specific route in express #15

@jacsamg

Description

@jacsamg

I would like to indicate a route for all static files and their subfolders.

To be able to access the assets from the route: 'domain.com/public/file.css'

Example:

app.use('/public', staticify.middleware);

However, by doing this, the 'getVersionedPath' method no longer works correctly.

I have browsed the code and modified it a bit, adding 'route' in the staticify options.

Example:

staticify(path.join(__dirname, './public'), { route: '/public' })

And I added this value in the 'buildVersionHash' method on line 57:

vers[`${opts.route}/${path.posix.relative(root, filePath)}`] = hash;

In this way the express route worked.

I know that validations were missing and possibly not the best way to do it, but I share it in case in the future they could officially include this possibility.

Thanks for staticify!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions