question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Only root route returns

See original GitHub issue

https://netlify-express.netlify.com/ renders, https://netlify-express.netlify.com/another returns a 404.

I’ve been trying to build a simple app using this as a boilerplate, and none of my defined routes work apart from /. Any ideas?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
neverendingqscommented, Mar 19, 2019

I haven’t had a chance to try it yet, but a rewrite rule might do the trick: https://www.netlify.com/docs/redirects/#rewrites-and-proxying

0reactions
AndreasLagonicommented, May 12, 2021

I have the same issue but only locally. When i deploy to Netlify the other routes is working fine but locally they don’t work.

router.get('/', (req, res) => {
  res.status(200).send("/")
});

router.get('/another', (req, res) => res.json({
  route: req.originalUrl
}));

app.use(bodyParser.json());
app.use('/.netlify/functions/server', router); // path must route to lambda
app.use('/', (req, res) => res.sendFile(path.join(__dirname, '../index.html')));

module.exports = app;
module.exports.handler = serverless(app);

/another will not work locally. Locally it will always go to root path. Any idea why? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Router V6 issue, only the root "/" route works, any other ...
What I find puzzling is that when I access these endpoints by directly typing in the url in the browser search bar it...
Read more >
Router tutorial: tour of heroes - Angular
Only call RouterModule.forRoot() in the root AppRoutingModule (or the AppModule if that's where you register top level application routes). In any other module ......
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
If your route only needs to return a view, you may use the Route::view method. ... Make sure to give the route's corresponding...
Read more >
Routing • Docs • SvelteKit
src/routes is the root route; src/routes/about creates an /about route ... If your load function can only run on the server — for...
Read more >
Rails Routing from the Outside In - Rails Edge Guides
Rails.application.routes.draw do resources :brands, only: [:index, ... GET, /photos/new, photos#new, return an HTML form for creating a new photo.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found