nuxt / bridge

🌉 Experience Nuxt 3 features on existing Nuxt 2 projects
MIT License
273 stars 29 forks source link

Can't use express router for api routes #77

Closed Gusb3ll closed 2 years ago

Gusb3ll commented 2 years ago

Environment

Reproduction

I wanted to build serverless api using express with these config

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"

Gusb3ll commented 2 years ago

Sorry, wrong issue. I meant nuxt3