Skip to content
Discussion options

You must be logged in to vote
const express = require('express');
const cors = require('cors');
const app = express();

app.use(cors({
  origin: 'https://xxxx.csb.app', // Replace with your sandbox preview URL
  credentials: true
}));

CodeSandbox previews run over secure HTTPS (csb.app), while your local API runs on unsecure HTTP. The browser blocks this cross-origin request by default.

To resolve this, configure your Express backend to allow the CodeSandbox origin:

  1. Install the CORS middleware: npm install cors
  2. Add it to your server configuration as shown above.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MischiefBrew
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