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

HELP! Wrong static file path with koa-static #488

Open
czweb2017 opened this issue Nov 23, 2018 · 2 comments
Open

HELP! Wrong static file path with koa-static #488

czweb2017 opened this issue Nov 23, 2018 · 2 comments

Comments

@czweb2017
Copy link

Document struct:
static/img/1.jpg
src/view
src/routes/index.js

Static file:
app.use(staticServe('static/'));

Router path:
router.get('/aaa/bbb', () => {
blabla...
ctx.render(.......)
})

But, I get a wrong path result on front end:
'http://localhost:8888/aaa/1.jpg' 404

HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@duylddev
Copy link

You should let nginx or apache serve static file instead of nodejs.
Link:
https://hashnode.com/post/why-is-it-not-recommended-to-serve-static-files-from-nodejs-ciibz8flv01duj3xt4lxuomp3

@czweb2017
Copy link
Author

Well, it was resolved. Please use '/css/index.css' on IMG or LINK elements. Don't lose '/' as begain.

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

2 participants