Skip to content

CORS Error #17

@paschaldev

Description

@paschaldev

After following the guide, I was getting CORS errors. From the network tab debugger, I saw a 404 error on the OPTIONS endpoint.

Image

Workaround

I had to add the option route and set the CORS header to get past the error.

Local Environment; Not tried in production

Browser: Firefox 148.0.2 (aarch64)
Convex: ^1.32.0
"@convex-dev/persistent-text-streaming": "^0.3.0",

http.route({
  path: '/workflow-stream',
  method: 'POST',
  handler: streamWorkflowContent,
});

http.route({
  path: '/workflow-stream',
  method: 'OPTIONS',
  handler: httpAction(async (_ctx, _request) => {
    return await new Promise((resolve) => {
      resolve(
        new Response(null, {
          headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': 'POST, OPTIONS',
            'Access-Control-Allow-Headers': 'Content-Type',
          },
        }),
      );
    });
  }),
});
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions