Skip to content

Commit

Permalink
Simplify CORS origin handling + Update README file
Browse files Browse the repository at this point in the history
  • Loading branch information
AbegaM committed Jun 30, 2023
1 parent 6241d2b commit f6c3ae7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Install Soul CLI with npm
## Usage

Soul is command line tool, after installing it,
Run `soul -d sqlite.db -p 8000 -c "*"` and it'll start a REST API on [http://localhost:8000](http://localhost:8000) and a Websocket server on [ws://localhost:8000](ws://localhost:8000).
Run `soul -d sqlite.db -p 8000` and it'll start a REST API on [http://localhost:8000](http://localhost:8000) and a Websocket server on [ws://localhost:8000](ws://localhost:8000).

```bash
Usage: soul [options]
Expand Down
10 changes: 7 additions & 3 deletions core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ app.use(bodyParser.json());
db.pragma('journal_mode = WAL');

// Enable CORS
const corsOrigin = config.cors.origin;
let corsOrigin = config.cors.origin;

if (corsOrigin.includes('*')) {
corsOrigin = '*';
}

const corsOptions = {
origin: corsOrigin[0] === '*' ? '*' : corsOrigin,
origin: corsOrigin,
};

app.use(cors(corsOptions));

// Log requests

if (config.verbose !== null) {
app.use(
expressWinston.logger({
Expand Down

0 comments on commit f6c3ae7

Please sign in to comment.