Fakultas Ilmu Komputer UI

Commit db1ad12c authored by Muhamad Istiady Kartadibrata's avatar Muhamad Istiady Kartadibrata
Browse files

configure env

parent 09722ac4
NODE_ENV = dev
DEV_URL = http://localhost:3001
PROD_URL = http://jitsi-kompeni.cs.ui.ac.id
\ No newline at end of file
......@@ -5,6 +5,7 @@ const bodyParser = require('body-parser');
const axios = require("axios");
var cors = require('cors')
var convert = require('xml-js');
require('dotenv').config()
// Constants
const PORT = 8000;
......@@ -15,21 +16,23 @@ app.use(cors())
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var routes = require('./routes');
app.get('/', (req, res) => {
const BASE_URL = process.env.NODE_ENV === "prod" || process.env.NODE_ENV ==="production" ? process.env.PROD_URL :process.env.DEV_URL
app.get('/api', (req, res) => {
res.status(200).json({
'message': "Hello World!"
})
})
app.post("/user", async (req, res, next) => {
app.post("/api/user", async (req, res, next) => {
const ticket = req.query.ticketId
const URL_REDIRECT = "http://localhost:3001"
try {
let {data} = await axios.post(
`https://sso.ui.ac.id/cas2/serviceValidate?ticket=${ticket}&service=${URL_REDIRECT}`
`https://sso.ui.ac.id/cas2/serviceValidate?ticket=${ticket}&service=${BASE_URL}`
)
data = data.replace(/>\s*/g, '>'); // Replace "> " with ">"
......
......@@ -98,6 +98,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment