Skip to content

Commit

Permalink
Change backend url
Browse files Browse the repository at this point in the history
  • Loading branch information
catherineisonline committed Jul 25, 2024
1 parent e7afcac commit 4485d3d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server.mjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import express, { json } from 'express';
import cors from 'cors';
import fetch from 'node-fetch';

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

const BACKEND_URL = process.env.BACKEND_URL;
const SHORTENER_API_URL = process.env.SHORTENER_API_URL;
app.use(cors());
app.use(json());

app.get('/', (req, res) => {
res.send('Server Deployed 🥳');
});

app.get('/shorten', async (req, res) => {
app.get(BACKEND_URL, async (req, res) => {
const { url } = req.query;

if (!url) {
return res.status(400).json({ success: false, message: 'URL parameter is required' });
}

try {
const response = await fetch(`https://ulvis.net/API/write/get?url=${encodeURIComponent(url)}`);
const response = await fetch(`${SHORTENER_API_URL}${encodeURIComponent(url)}`);
const data = await response.json();

if (data.success) {
Expand Down

0 comments on commit 4485d3d

Please sign in to comment.