-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
trouble with routes #87
Comments
This comment has been minimized.
This comment has been minimized.
doesnt helps |
This comment has been minimized.
This comment has been minimized.
You didn't add router |
Mhh... also works... const express = require("ultimate-express");
const app = express();
const router = express.Router();
router.get("/", (req, res) => res.status(200).send(""));
router.get("/de/", (req, res) => res.status(200).send(""));
router.get("/gallery", (req, res) => res.status(200).send(""));
router.get("/gallery/page/:page", (req, res) =>
res.status(200).send(req.params.page)
);
router.get("/de/gallery", (req, res) => res.status(200).send(""));
router.get("/de/gallery/page/:page", (req, res) => res.status(200).send(""));
app.use('/', router);
app.listen(13333, () => {
console.log("Server is running at http://localhost:13333");
}); |
I can replicate it when I add a trailing slash at the end of request |
Yes! also to me
|
It seem uWebSockets behaviour uNetworking/uWebSockets#1049 |
in my case with ultimate-express /gallery/page/4/ 404 how to solve it? just add one more router?
and this variant doesnt works ALSO!!!
|
@dimdenGD a possible workaround is redirect all request to non-trailing slash url #createRequestHandler() {
this.uwsApp.any('/*', async (res, req) => {
const { request, response } = this.handleRequest(res, req);
// redirect to non-trailing slash url
const host = req.getHeader('host')
const path = req.getUrl()
const query = req.getQuery()
if(path.endsWith('/') && path != '/') return res.writeStatus('301').writeHeader('Location',`//${host}${path.slice(0,-1)}${query?'?'+query:''}`).end()
const matchedRoute = await this._routeRequest(request, response);
if(!matchedRoute && !response.headersSent && !response.aborted) {
response.status(404);
this._sendErrorPage(request, response, `Cannot ${request.method} ${request.path}`, false);
}
});
} |
Is must be configureble for some flags. |
Sure! Among other things, for SEO purposes, URLs with and without trailing slashes must be treated as two different URLs. If you want to serve the same content, one must perform a 301 redirect to the other. |
I want just set flag for do it configureble. And I want to see it in documentation |
this is my proposal #90 |
Fixed in 1.3.18 |
I have this routes
with express works ok but with ultimate-express cant find
/gallery/page/4 for example and I have 404 on this route
The text was updated successfully, but these errors were encountered: