Skip to content

Is it possible to send all routes to /index? #2065

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

Closed
OutThisLife opened this issue May 25, 2017 · 4 comments
Closed

Is it possible to send all routes to /index? #2065

OutThisLife opened this issue May 25, 2017 · 4 comments

Comments

@OutThisLife
Copy link
Contributor

I don't want to build a router, so I have this:

app.prepare().then(() => {
	createServer((req, res) => {
		const
			parsedUrl = parse(req.url, true),
			{ pathname, query } = parsedUrl,
			isFile = pathname.match(/(static)/)

		if (isFile === null) app.render(req, res, '/', query)
		else handle(req, res, parsedUrl)
	}).listen(port, err => {
		if (err) throw err
		console.log(`> Ready on localhost:${port}`)
	})
})

It kind of works but client side rendering breaks and I get a 404 with a Node server error like "Client pings, but there's no entry for page"

Thoughts?

@timneutkens
Copy link
Member

Maybe this helps? #257

@arunoda
Copy link
Contributor

arunoda commented May 26, 2017

@OutThisLife I didn't exactly get the issue.

But you don't need to create a router on your own.
Simply use express or something you are familiar with: https://learnnextjs.com/basics/server-side-support-for-clean-urls

@OutThisLife
Copy link
Contributor Author

Solved my 'problem' by just using https://github.com/fridays/next-routes

@timneutkens
Copy link
Member

Awesome 👍

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants