Skip to content

Commit

Permalink
fix(module): remove prefix for tailwind viewer route on nuxt 2
Browse files Browse the repository at this point in the history
fix bug: #510
  • Loading branch information
chettapong committed Jul 29, 2022
1 parent 5cec9fc commit 35f42a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ export default defineNuxtModule<ModuleOptions>({
const route = '/_tailwind'
const createServer = await import('tailwind-config-viewer/server/index.js').then(r => r.default || r) as any
const { withTrailingSlash, withoutTrailingSlash } = await import('ufo')
const _viewerDevMiddleware = createServer({ tailwindConfigProvider: () => tailwindConfig, routerPrefix: route }).asMiddleware()
const routerPrefix = isNuxt3() ? route : undefined
consola.log('routerPrefix', routerPrefix)
const _viewerDevMiddleware = createServer({ tailwindConfigProvider: () => tailwindConfig, routerPrefix }).asMiddleware()
const viewerDevMiddleware = (req, res) => {
if (req.originalUrl === withoutTrailingSlash(route)) {
res.writeHead(301, { Location: withTrailingSlash(req.originalUrl) })
Expand Down

0 comments on commit 35f42a5

Please sign in to comment.