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

A minimal example #3

Open
ochsec opened this issue Sep 13, 2019 · 0 comments
Open

A minimal example #3

ochsec opened this issue Sep 13, 2019 · 0 comments

Comments

@ochsec
Copy link

ochsec commented Sep 13, 2019

Hi, since there's no example, could you tell me where I went wrong

const express = require('express');
const spaRouter = require('express-spa-router');
const app = express();
const port = 3000;

app.get('/', (req, res) => res.send('Hello World!'));


app.use((spaRouter)(app, {
    ignore: ['api'],
    noRoute: function(req, res, next) {
            res.redirect('/');
    }
}));

app.get('/api', (req, res) => res.send({ hello: 'world' }));

app.listen(port, () => console.log(`Example app listening on port ${port}!`));
  1. ip:3000/ --> hello world
  2. ip:3000/foo --> TypeError: Cain't read property 'get' of undefined
  3. ip:3000/api --> {"hello":"world"}

It seems like (2) should return 'hello world'.

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