arash16 / nuxt-ssr-cache

Cache middleware for nuxt's SSR rendering.
MIT License
295 stars 64 forks source link

The "path" argument must be of type string. Received type undefined #5

Closed panchenyu0928 closed 5 years ago

panchenyu0928 commented 5 years ago

/lib/middleware.js if config.cache.useHostPrefix === true context.req.hostname is undefined

arash16 commented 5 years ago

@panchenyu0928 I guess you're not using express, and hostname remains undefined. express uses 'X-Forwarded-Host' header field (if configured to trust proxy) to provide that field. I have fixed it to use req.host if req.hostname is not provided, but if you're behind reverse proxy, It won't have a meaningfull value.

arash16 commented 5 years ago

Also if you're not serving multiple domains, disabling useHostPrefix saves you some memory.

panchenyu0928 commented 5 years ago

@arash16 Thank you!😊