Making REST API requests from chrome extension to replit


I am trying to make a ultra simple app (chrome extension) connecting to an ultra simple server (replit).

Replit code using express:

app.get('/hello, (req, res) => res.send("hello world"));

chrome extension (Service_worker, manifest v3):

res = await fetch("");

But this does not seem to work. Is there anything i need to do or configure on the server side to allow for requests from a chrome extension ? The server itself works when using a a browser.

has someone setup something similar?

1 Like

Make sure your fetching the right link, it should be https://<repl name>.<username> If you could post a link to your server that might help the community help with your issue.

Hello I have set up something famillair. Is there an error you get? could you share the full code (just view not edit) with us?

1 Like

I could be wrong, but it sounds like you are a victim of a CORS error. This is a system implemented by browsers to prevent sites from stealing a user’s data on other sites.

You’ve got two main options:

  1. Add your Repl’s origin to the host_permissions key in your manifest. This tells Chrome to bypass CORS for requests from your extension’s service worker.
    "host_permissions": ["*://*"]
  2. Or, you can configure your Express server to allow requests from your extension’s origin. This can easily be done with the cors module
      origin: "chrome-extension://YOUR_EXTENSION_ID",
      optionsSuccessStatus: 200

Good info! I actually needed this! no more looking on stackoverflow :kekw:


Hey there! are you making a chrome replit extension that posts some data to a server?
Well, you can’t do that. Why? because the request are blocked by CORS for some security reasons.

Replit will only allow you to fetch to a domain.

1 Like