Skip to content

Commit

Permalink
update/docker-integration
Browse files Browse the repository at this point in the history
Arnav committed Mar 16, 2024
1 parent 78d2cb8 commit 4b4d6a3
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions url-shortener/servers/express-js/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# TODO: error building; possible: node version
FROM node:21-alpine
FROM node:18
LABEL authors="arnavrneo"

WORKDIR /app
@@ -8,6 +7,8 @@ COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 5678

CMD [ "node", "index.js" ]
10 changes: 9 additions & 1 deletion url-shortener/servers/express-js/index.js
Original file line number Diff line number Diff line change
@@ -16,9 +16,17 @@ const PORT = process.env.PORT;
const app = express();

const allowedOrigins = ["http://localhost:3000", "http://localhost:3000/signup", "http://localhost:3000/main"]
//const allowedOrigins = ["*"]

app.use(express.json());
app.use(cors({allowedOrigins, credentials: true, origin: true}));
app.use(cors({origin: allowedOrigins, credentials: true})); //This one kills the server after cors error
// app.use(function(req, res, next) {
// res.setHeader('Access-Control-Allow-Origin', '*');
// res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
// res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
// res.setHeader('Access-Control-Allow-Credentials', true);
// next();
// });
app.use(cookieParser());

mongoose.connect(process.env.MONGODB_URI)
4 changes: 2 additions & 2 deletions url-shortener/servers/express-js/rdClient/redisClient.js
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ import {createClient} from "redis";
const client = createClient({
password: process.env.REDIS_PASS,
socket: {
host: 'redis-15391.c326.us-east-1-3.ec2.cloud.redislabs.com',
port: 15391,
host: process.env.REDIS_URI,
port: process.env.REDIS_PORT,
tls: {rejectUnauthorized: false},
}
});

0 comments on commit 4b4d6a3

Please sign in to comment.