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

Static serve middleware is not working #16

Open
1 of 2 tasks
jbenguira opened this issue Mar 10, 2021 · 3 comments
Open
1 of 2 tasks

Static serve middleware is not working #16

jbenguira opened this issue Mar 10, 2021 · 3 comments

Comments

@jbenguira
Copy link

jbenguira commented Mar 10, 2021

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login

Minimal reproducible repo

create a folder with index.js
Also create a subfolder "static" containing index.html with "hello world" in it

const nanoexpress = require('nanoexpress');
const staticServe = require('@nanoexpress/middleware-static-serve/cjs');
const path = require('path');
const app = nanoexpress();
app.use(staticServe(path.join(__dirname, 'static')));
app.get('/', (req, res) => {
    return res.send({ status: 'ok' });
});
app.listen(3000);

then open http://localhost:3000/index.html
this return: {"code":404,"message":"The route does not exist"}
but http://localhost:3000/ do return "hello world"

so the issue seems to be the routing for all other paths except "/"

Environment

  • Node/npm version: v12.14.0 / v 6.13.4
  • OS: Ubunutu 20.04
    "dependencies": {
    "@nanoexpress/middleware-static-serve": "^1.0.1",
    "nanoexpress": "^2.4.9"
    }
@dalisoft dalisoft transferred this issue from nanoexpress/nanoexpress Mar 11, 2021
@dalisoft
Copy link
Member

@jbenguira If you can fix it now, please create PR, i'll look into at end of month if i can. Thanks for trying out nanoexpress

@cspandey
Copy link

How can I serve static files on specific routes? I want to serve index.html file on "/" route of react build folder. any idea?

@dalisoft
Copy link
Member

I look into in next month as i hope i'll can get some free time. Otherwise i hope anyone can submit PR

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

3 participants