Skip to content

How do I set addContentTypeParser only to specific paths? #5306

Answered by matthyk
adaboese asked this question in General
Discussion options

You must be logged in to vote

Encapsulate your catch-all route within a plugin and remove all content-type parsers.

export default function (app) {
  app.removeAllContentTypeParsers()

  app.all('*', async (request, reply) => {
    try {
      const handler = createRequestHandler({
        // https://github.com/remix-run/remix/issues/8343#issuecomment-1867179525
        // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
        // @ts-ignore - expected type mismatch
        build: () => vite.ssrLoadModule('virtual:remix/server-build'),
      });
  
      return handler(request, reply);
    } catch (error) {
      return reply.status(500).send(error);
    }
  });

  
}

Replies: 1 comment 1 reply

Comment options

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

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