Skip to content
Discussion options

You must be logged in to vote

Here's a robust solution that handles bots and random traffic while avoiding unnecessary server responses.

  1. define a catch-all route
// app/$.jsx
import { json } from '@remix-run/node';

const NotImplementedError = () => new Response(null, {
  status: 501,
  statusText: 'NotImplemented'
});

const NotFoundError = () => json({
  error: 'NotFound',
}, {
  status: 404,
});

// handle baddies
export function action() {
  throw NotImplementedError();
}

// throw a json response to raise our root error boundary
export function loader() {
  throw NotFoundError();
}

export default function Index() {
  return null;
}
  1. Define a Root Error Boundary to control the response body and provide a good UX

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@danthegoodman1
Comment options

Answer selected by danthegoodman1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants