Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native nuxt serverMiddleware functionality with this setup does not work #10

Open
krisztianodor opened this issue Apr 27, 2019 · 1 comment

Comments

@krisztianodor
Copy link

ServerMiddleware documentation

My setup

// app/serverMiddleware/test.js
module.exports = function (req, res, next) {
    console.log('It works!');
    next();
};
// nuxt.config.js
serverMiddleware: [
    '~/serverMiddleware/test'
],

Expected behavior:

At firebase serve on new page load 'It works!' string is logged on the server.

Actual behavior:

At firebase serve on new page load 'It works!' string is not logged on the server.

During development it works fine...

@krisztianodor
Copy link
Author

krisztianodor commented Apr 27, 2019

After some read i think the problem is that the serverMiddleware stuffs are not getting bundled in the build. (but why...?)

Solution

Modify firebase nuxt config:

// functions/index.js
const config = {
  dev: false,
  buildDir: '.nuxt',
  build: {
    publicPath: '/assets/'
  },
  serverMiddleware: [
    '~/serverMiddleware/test'
  ],
}

Copy serverMiddleware stuffs to firebase dist/server:

// package.json
"copy": "...;cp -R app/serverMiddleware dist/server",

According to this (the bundle is not containing everything) we should deploy the whole app directory to the firebase...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant