Nuxt blocks Fastify routes
See original GitHub issueIt appears that Nuxt nuxt.render
method blocks Fastify routes.
Reproduction
Use npx create-nuxt-app <project-name>
with the following configuration
create-nuxt-app v2.15.0
✨ Generating Nuxt.js project in Test
? Project name Test
? Project description My awe-inspiring Nuxt.js project
? Author name
? Choose programming language JavaScript
? Choose the package manager Yarn
? Choose UI framework Vuetify.js
? Choose custom server framework Fastify
? Choose Nuxt.js modules Axios, Progressive Web App (PWA) Support, DotEnv
? Choose linting tools ESLint, Prettier
? Choose test framework AVA
? Choose rendering mode Universal (SSR)
? Choose development tools jsconfig.json (Recommended for VS Code)
yarn run v1.22.4
Then add a simple fastify route to /server/index.js
fastify.get('/test', (request, reply) => {
reply.send({ hello: 'world' })
})
Result
Fastify routes returns 404
What i have tried
- Disabling Nuxt render (
fastify.use(nuxt.render)
) does allow Fastify routes to be exposed
I guess adding a whitelist for Fastify routes and handling that with Nuxt.render would work, but that would be inconvenient.
Thank you
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to create api routes with Fastify and Nuxt? - Stack Overflow
js process with a non-zero exit code. How can I add api routes using Fastify and Nuxt? I want to avoid creating a...
Read more >Plugins - Fastify
Fastify allows the user to extend its functionalities with plugins. A plugin can be a set of routes, a server decorator, or whatever....
Read more >The Ultimate Nuxt API Setup
First we need to use a plugin to inject $api everywhere. If the request is running entirely on the server (SSR), we assign...
Read more >How to build a blazingly fast API with Fastify - LogRocket Blog
5 important Fastify plugins you should know · 1. Installation and requirements · 2. Create server.js · 3. Adding CRUD routes · 4....
Read more >Build a CRUD API with Fastify - DEV Community
The next thing we would do is to assign a port to a PORT variable, ... Now let's create a simple route for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah I noticed the same thing. I don’t think nuxt’s
render
method is callingnext
.For anyone else, I followed the whitelist approach as noted:
@paulogr Unfortunately it is not universally possible because this means we need to load/init the entire SSR bundle even for client-side calls to functions. But the good news is that functions supporting a similar feature called services so we can have axios service.