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

feat/enable the path for map-editor #3

Open
leeduckgo opened this issue Oct 12, 2024 · 0 comments
Open

feat/enable the path for map-editor #3

leeduckgo opened this issue Oct 12, 2024 · 0 comments

Comments

@leeduckgo
Copy link
Collaborator

now is 404.

To address the issue of showing a 404 error when directly visiting a path like https://roguelike.rootmud.xyz/play, you'll need to make some changes to your server configuration or routing setup. This is typically an issue with single-page applications (SPAs) when using client-side routing.

Since the specific file you've shown (`Canvas.tsx`) is not directly related to routing, I'll provide a general solution that you can implement in your project:

1. If you're using a static file server (like Nginx), you'll need to configure it to serve your `index.html` for all routes. Here's an example Nginx configuration:

```nginx
location / {
  try_files $uri $uri/ /index.html;
}
  1. If you're using a Node.js server (like Express), you can add a catch-all route:
const express = require('express');
const path = require('path');
const app = express();

// Serve static files
app.use(express.static(path.join(__dirname, 'build')));

// Catch-all route
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(3000);
  1. If you're using a service like Netlify or Vercel, you can create a _redirects file (for Netlify) or vercel.json (for Vercel) in your project root:

For Netlify (_redirects):

/*    /index.html   200

For Vercel (vercel.json):

{
  "routes": [
    { "src": "/(.*)", "dest": "/index.html" }
  ]
}

These configurations will ensure that all routes are directed to your main index.html file, allowing your client-side router to handle the routing.

Remember to rebuild and redeploy your application after making these changes. The exact implementation will depend on your hosting setup and build process.

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

1 participant