Skip to content

Commit

Permalink
resolving error
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilean12 committed May 24, 2024
1 parent 77867cb commit 348b70d
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 15 deletions.
10 changes: 8 additions & 2 deletions Backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ const app = express();
const port = process.env.PORT || 3000; // Use port 3000 for your setup

// Middleware
app.use(cors());
app.use(express.json());
const corsOptions = {
origin: 'https://stockdata12.z6.web.core.windows.net', // Your frontend URL
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true,
optionsSuccessStatus: 200
};

app.use(cors(corsOptions));app.use(express.json());
app.use(cookieParser());

// Routes
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Frontend/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Vite + React + TS</title>
<script type="module" crossorigin src="/assets/index-DJD781ha.js"></script>
<title>stock monitoring platform</title>
<script type="module" crossorigin src="/assets/index-Dwf-HOsN.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BYonyOBv.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion Frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Vite + React + TS</title>
<title>stock monitoring platform</title>
</head>
<link rel="stylesheet" type="text/css" href="./index.css">

Expand Down
4 changes: 2 additions & 2 deletions Frontend/src/component/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// const handleLogin = async (e) => {
// e.preventDefault();
// try {
// const response = await axios.post('http://localhost:3000/api/auth/login', { email, password });
// const response = await axios.post('https://stock-app12.azurewebsites.net/api/auth/login', { email, password });
// localStorage.setItem('accessToken', response.data.token); // Store the access token in local storage
// setAuthToken(response.data.token); // Store the access token in AuthContext
// window.location.href = '/Profile';
Expand Down Expand Up @@ -116,7 +116,7 @@ const Login = () => {
const handleLogin = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
try {
const response = await axios.post('http://localhost:3000/api/auth/login', { email, password });
const response = await axios.post('https://stock-app12.azurewebsites.net/api/auth/login', { email, password });
localStorage.setItem('accessToken', response.data.token);
setAuthToken(response.data.token);
window.location.href = '/Profile';
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/component/Auth/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const Register: React.FC = () => {
}

try {
const response = await axios.post('http://localhost:3000/api/auth/signup', {
const response = await axios.post('https://stock-app12.azurewebsites.net/api/auth/signup', {
name,
email,
password,
Expand Down
4 changes: 2 additions & 2 deletions Frontend/src/component/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Profile: React.FC = () => {
navigate('/login');
return;
}
const response = await axios.get<UserData>('http://localhost:3000/api/auth/profile', {
const response = await axios.get<UserData>('https://stock-app12.azurewebsites.net/api/auth/profile', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
Expand All @@ -58,7 +58,7 @@ const Profile: React.FC = () => {
navigate('/login');
return;
}
const response = await axios.patch<UserData>('http://localhost:3000/api/auth/profile', {
const response = await axios.patch<UserData>('https://stock-app12.azurewebsites.net/api/auth/profile', {
name,
gender,
}, {
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/component/Stocks/StockDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const StockDashboard = () => {
throw new Error('No authentication token found');
}
const response = await axios.post(
'http://localhost:3000/api/watch/watchlist',
'https://stock-app12.azurewebsites.net/api/watch/watchlist',
{ symbols: [stockData.symbol] },
{ headers: { Authorization: `Bearer ${authToken}` } }
);
Expand Down
4 changes: 2 additions & 2 deletions Frontend/src/component/Watchlist/Watchlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Watchlist = () => {
if (!authToken) {
throw new Error('No authentication token found');
}
const response = await axios.get<string[]>('http://localhost:3000/api/watch/watchlist', {
const response = await axios.get<string[]>('https://stock-app12.azurewebsites.net/api/watch/watchlist', {
headers: { Authorization: `Bearer ${authToken}` },
});
if (response.status === 200) {
Expand Down Expand Up @@ -83,7 +83,7 @@ const Watchlist = () => {
throw new Error('No authentication token found');
}
const response = await axios.delete(
'http://localhost:3000/api/watch/watchlist',
'https://stock-app12.azurewebsites.net/api/watch/watchlist',
{
headers: { Authorization: `Bearer ${authToken}` },
data: { symbol },
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/hooks/useSignup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const useSignup = () => {
try {
setError(null);
setLoading(true);
const res = await fetch("http://localhost:3000/api/auth/signup", {
const res = await fetch("https://stock-app12.azurewebsites.net/api/auth/signup", {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(values),
Expand Down

0 comments on commit 348b70d

Please sign in to comment.