Skip to content

Commit

Permalink
cors error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
angelalvaigle committed Dec 6, 2024
1 parent 581e611 commit a9c7513
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const statServiceUrl = process.env.STAT_SERVICE_URL || 'http://localhost:8004';

app.use(
cors({
origin: 'http://localhost:3000',
origin: (origin, callback) => {
callback(null, true); // Permite cualquier origen
},
credentials: true,
allowedHeaders: ['Authorization', 'Content-Type'],
})
Expand Down
8 changes: 5 additions & 3 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
import express from 'express';
import mongoose from 'mongoose';
import cors from 'cors';
import cookieParser from 'cookie-parser';
//import cookieParser from 'cookie-parser';
import userRouter from './user-router.js';

const app = express();
const port = 8001;

app.use(
cors({
origin: 'http://localhost:8000', // Dirección del gateway.
origin: (origin, callback) => {
callback(null, true); // Permite cualquier origen
},
credentials: true, // Permite enviar cookies.
})
);
app.use(express.json());
app.use(cookieParser());
//app.use(cookieParser());

// Connect to MongoDB
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb';
Expand Down

0 comments on commit a9c7513

Please sign in to comment.