Closed Gusb3ll closed 2 years ago
Windows_NT
v16.14.2
3.0.0-27495976.e31c604
yarn@4.0.0-rc.2
vite
meta
components
css
plugins
serverMiddleware
modules
buildModules
typescript
windicss
-
nuxt-windicss@2.2.10
@vueuse/nuxt@8.2.5
@pinia/nuxt@0.1.8
I wanted to build serverless api using express with these config
nuxt.config.ts
serverMiddleware: [{ path: '/api', handler: '~/server/api' }]
server/api/index.ts
import express from 'express' import authRouter from './routes/v1/auth'
const app = express() app.use(express.json())
app.use('/v1/auth', authRouter)
app.use((req, res) => { res.status(200).json({ Status: 'API OK', created: Date.now().toString(), version: '1.0.0' }) })
export default app
- server/api/routes/auth.ts
import { Router } from 'express'
import stellar from '../../objects/stellar'
const authRouter = Router()
authRouter.get('/login', (req, res) => { return res.redirect(stellar.getLoginUrl()) })
export default authRouter
### Describe the bug When I try to access ```/api/v1/auth/login``` I got the response
{ "url": "/api/v1/auth/login", "statusCode": 404, "statusMessage": "Page not found: /api/v1/auth/login", "message": "Page not found: /api/v1/auth/login" }
but with only ```/api``` I got
{ "Status": "API OK", "created": "1649827202155", "version": "1.0.0" }
### Additional context _No response_ ### Logs ```shell When I tried to access /api/v1/auth/login``` I got the following message on the console
[Vue Router warn]: No match found for location with path "/api/v1/auth/login"
Sorry, wrong issue. I meant nuxt3
Environment
Windows_NT
v16.14.2
3.0.0-27495976.e31c604
yarn@4.0.0-rc.2
vite
meta
,components
,css
,plugins
,serverMiddleware
,modules
,buildModules
,typescript
,windicss
-
nuxt-windicss@2.2.10
,@vueuse/nuxt@8.2.5
,@pinia/nuxt@0.1.8
Reproduction
I wanted to build serverless api using express with these config
nuxt.config.ts
server/api/index.ts
const app = express() app.use(express.json())
app.use('/v1/auth', authRouter)
app.use((req, res) => { res.status(200).json({ Status: 'API OK', created: Date.now().toString(), version: '1.0.0' }) })
export default app
import { Router } from 'express'
import stellar from '../../objects/stellar'
const authRouter = Router()
authRouter.get('/login', (req, res) => { return res.redirect(stellar.getLoginUrl()) })
export default authRouter
{ "url": "/api/v1/auth/login", "statusCode": 404, "statusMessage": "Page not found: /api/v1/auth/login", "message": "Page not found: /api/v1/auth/login" }
{ "Status": "API OK", "created": "1649827202155", "version": "1.0.0" }
[Vue Router warn]: No match found for location with path "/api/v1/auth/login"