Code Monkey home page Code Monkey logo

Comments (5)

mcollina avatar mcollina commented on May 13, 2024 3

You should disable the decorator: https://github.com/fastify/fastify-static#disabling-reply-decorator.

As for the multiple directory/array, would you like to send a PR?

from fastify-static.

borodadada avatar borodadada commented on May 13, 2024

mcollina thanks man. Work!

fastify.register( require('fastify-static'), { root: path.join(__dirname, 'dist'), prefix: '/dist/', decorateReply: false } )
fastify.register( require('fastify-static'), { root: path.join(__dirname, 'public'), prefix: '/public/', decorateReply: false } )

from fastify-static.

tapiamcclung avatar tapiamcclung commented on May 13, 2024

Hi, I am very new to fastify so please bear with me. After reading #100 and this entry, I tried this and it worked earlier today, but all of the sudden I am getting:

     reply.sendFile('index.html')
            ^

TypeError: reply.sendFile is not a function

Any hints? I registered another path and it works, but how can I get the original path to work again?

from fastify-static.

Eomm avatar Eomm commented on May 13, 2024

@tapiamcclung
the sendFile is a decorator added by this plugin.

If you are calling this method in an encapulated context without the fastify-static plugin registered you will get that error.
So you have a context with this plugin and another context without. So you should move the registration of the plugin in a higher context or load it in the context without it.
If you have trouble doing so, please open a new issue with your code in order to help you better.

I'm closing this issue since @borodadada solved the problem 👍

from fastify-static.

stefanocudini avatar stefanocudini commented on May 13, 2024

As for the multiple directory/array, would you like to send a PR?

@mcollina Is there any other contribution regarding this?
I have very different directories and would like to avoid placing a require inside a loop.. (e' brutto)

from fastify-static.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.