Girish Jeswani commited on
Commit
4a9d22d
·
1 Parent(s): 5fb1edb

update environment variables

Browse files
phd-advisor-frontend/src/components/ExportButton.js CHANGED
@@ -63,7 +63,7 @@ const ExportButton = ({ hasMessages = false, currentSessionId = null, authToken
63
  const endpoint = selectedTypeData.endpoint;
64
 
65
  // Build the URL with session ID if available
66
- let url = `http://localhost:8000/${endpoint}?format=${format}`;
67
  if (currentSessionId) {
68
  url += `&chat_session_id=${currentSessionId}`;
69
  }
 
63
  const endpoint = selectedTypeData.endpoint;
64
 
65
  // Build the URL with session ID if available
66
+ let url = `${process.env.REACT_APP_API_URL}/${endpoint}?format=${format}`;
67
  if (currentSessionId) {
68
  url += `&chat_session_id=${currentSessionId}`;
69
  }
phd-advisor-frontend/src/components/FileUpload.js CHANGED
@@ -44,7 +44,7 @@ const FileUpload = ({ onFileUploaded, isUploading, onUploadStart, currentChatSes
44
  formData.append('file', file);
45
 
46
  try {
47
- let uploadUrl = 'http://localhost:8000/upload-document';
48
 
49
  console.log('=== DOCUMENT UPLOAD DEBUG ===');
50
  console.log('currentChatSessionId:', currentChatSessionId);
 
44
  formData.append('file', file);
45
 
46
  try {
47
+ let uploadUrl = `${process.env.REACT_APP_API_URL}/upload-document`;
48
 
49
  console.log('=== DOCUMENT UPLOAD DEBUG ===');
50
  console.log('currentChatSessionId:', currentChatSessionId);
phd-advisor-frontend/src/components/Login.js CHANGED
@@ -53,7 +53,7 @@ const Login = ({ onNavigateToSignup, onNavigateToHome }) => {
53
  setIsLoading(true);
54
 
55
  try {
56
- const response = await fetch('http://localhost:8000/auth/login', {
57
  method: 'POST',
58
  headers: {
59
  'Content-Type': 'application/json',
 
53
  setIsLoading(true);
54
 
55
  try {
56
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/auth/login`, {
57
  method: 'POST',
58
  headers: {
59
  'Content-Type': 'application/json',
phd-advisor-frontend/src/components/Sidebar.js CHANGED
@@ -73,7 +73,7 @@ const Sidebar = ({
73
 
74
  const fetchChatSessions = async () => {
75
  try {
76
- const response = await fetch('http://localhost:8000/api/chat-sessions', {
77
  headers: {
78
  'Authorization': `Bearer ${authToken}`,
79
  'Content-Type': 'application/json'
@@ -117,7 +117,7 @@ const Sidebar = ({
117
 
118
  if (window.confirm('Are you sure you want to delete this chat?')) {
119
  try {
120
- const response = await fetch(`http://localhost:8000/api/chat-sessions/${sessionId}`, {
121
  method: 'DELETE',
122
  headers: {
123
  'Authorization': `Bearer ${authToken}`,
 
73
 
74
  const fetchChatSessions = async () => {
75
  try {
76
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/api/chat-sessions`, {
77
  headers: {
78
  'Authorization': `Bearer ${authToken}`,
79
  'Content-Type': 'application/json'
 
117
 
118
  if (window.confirm('Are you sure you want to delete this chat?')) {
119
  try {
120
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/api/chat-sessions/${sessionId}`, {
121
  method: 'DELETE',
122
  headers: {
123
  'Authorization': `Bearer ${authToken}`,
phd-advisor-frontend/src/components/Signup.js CHANGED
@@ -91,7 +91,7 @@ const Signup = ({ onNavigateToLogin, onNavigateToHome }) => {
91
  setIsLoading(true);
92
 
93
  try {
94
- const response = await fetch('http://localhost:8000/auth/signup', {
95
  method: 'POST',
96
  headers: {
97
  'Content-Type': 'application/json',
 
91
  setIsLoading(true);
92
 
93
  try {
94
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/auth/signup`, {
95
  method: 'POST',
96
  headers: {
97
  'Content-Type': 'application/json',
phd-advisor-frontend/src/pages/ChatPage.js CHANGED
@@ -52,7 +52,7 @@ const ChatPage = ({ user, authToken, onNavigateToHome, onSignOut }) => {
52
 
53
  const fetchCurrentProvider = async () => {
54
  try {
55
- const response = await fetch('http://localhost:8000/current-provider');
56
  if (response.ok) {
57
  const data = await response.json();
58
  setCurrentProvider(data.current_provider);
@@ -70,7 +70,7 @@ const ChatPage = ({ user, authToken, onNavigateToHome, onSignOut }) => {
70
 
71
  setIsProviderSwitching(true);
72
  try {
73
- const response = await fetch('http://localhost:8000/switch-provider', {
74
  method: 'POST',
75
  headers: {
76
  'Content-Type': 'application/json',
@@ -126,7 +126,7 @@ const ChatPage = ({ user, authToken, onNavigateToHome, onSignOut }) => {
126
  ? `${firstMessage.substring(0, 30)}...`
127
  : `Chat ${new Date().toLocaleDateString()}`;
128
 
129
- const response = await fetch('http://localhost:8000/api/chat-sessions', {
130
  method: 'POST',
131
  headers: {
132
  'Authorization': `Bearer ${authToken}`,
@@ -161,7 +161,7 @@ const loadChatSession = async (sessionId) => {
161
  setIsLoadingSession(true);
162
  try {
163
  // Use the new switch-chat endpoint that syncs context
164
- const response = await fetch('http://localhost:8000/switch-chat', {
165
  method: 'POST',
166
  headers: {
167
  'Authorization': `Bearer ${authToken}`,
@@ -190,7 +190,7 @@ const loadChatSession = async (sessionId) => {
190
  setThinkingAdvisors([]);
191
 
192
  // Also get the session title from MongoDB
193
- const sessionResponse = await fetch(`http://localhost:8000/api/chat-sessions/${sessionId}`, {
194
  headers: {
195
  'Authorization': `Bearer ${authToken}`,
196
  'Content-Type': 'application/json'
@@ -214,7 +214,7 @@ const saveMessageToSession = async (message) => {
214
  if (!currentSessionId || !authToken) return;
215
 
216
  try {
217
- await fetch(`http://localhost:8000/api/chat-sessions/${currentSessionId}/messages`, {
218
  method: 'POST',
219
  headers: {
220
  'Authorization': `Bearer ${authToken}`,
@@ -238,7 +238,7 @@ const updateSessionTitle = async (sessionId, newTitle) => {
238
  if (!sessionId || !authToken) return;
239
 
240
  try {
241
- await fetch(`http://localhost:8000/api/chat-sessions/${sessionId}`, {
242
  method: 'PUT',
243
  headers: {
244
  'Authorization': `Bearer ${authToken}`,
@@ -268,7 +268,7 @@ const handleNewChat = async (sessionId = null) => {
268
  // Creating completely new chat with fresh context
269
  try {
270
  // Step 1: Reset memory session
271
- const response = await fetch('http://localhost:8000/new-chat', {
272
  method: 'POST',
273
  headers: {
274
  'Authorization': `Bearer ${authToken}`,
@@ -402,7 +402,7 @@ const handleNewChat = async (sessionId = null) => {
402
 
403
  console.log('Sending message with session ID:', currentSessionId); // Debug log
404
 
405
- const response = await fetch('http://localhost:8000/chat-sequential', {
406
  method: 'POST',
407
  headers: headers,
408
  body: JSON.stringify({
@@ -491,7 +491,7 @@ const handleNewChat = async (sessionId = null) => {
491
  setThinkingAdvisors([replyContext.persona_id]);
492
 
493
  try {
494
- const response = await fetch('http://localhost:8000/reply-to-advisor', {
495
  method: 'POST',
496
  headers: {
497
  'Content-Type': 'application/json',
@@ -575,7 +575,7 @@ const handleNewChat = async (sessionId = null) => {
575
  setThinkingAdvisors([advisorId]);
576
 
577
  try {
578
- const response = await fetch(`http://localhost:8000/chat/${advisorId}`, {
579
  method: 'POST',
580
  headers: {
581
  'Content-Type': 'application/json',
 
52
 
53
  const fetchCurrentProvider = async () => {
54
  try {
55
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/current-provider`);
56
  if (response.ok) {
57
  const data = await response.json();
58
  setCurrentProvider(data.current_provider);
 
70
 
71
  setIsProviderSwitching(true);
72
  try {
73
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/switch-provider`, {
74
  method: 'POST',
75
  headers: {
76
  'Content-Type': 'application/json',
 
126
  ? `${firstMessage.substring(0, 30)}...`
127
  : `Chat ${new Date().toLocaleDateString()}`;
128
 
129
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/api/chat-sessions`, {
130
  method: 'POST',
131
  headers: {
132
  'Authorization': `Bearer ${authToken}`,
 
161
  setIsLoadingSession(true);
162
  try {
163
  // Use the new switch-chat endpoint that syncs context
164
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/switch-chat`, {
165
  method: 'POST',
166
  headers: {
167
  'Authorization': `Bearer ${authToken}`,
 
190
  setThinkingAdvisors([]);
191
 
192
  // Also get the session title from MongoDB
193
+ const sessionResponse = await fetch(`${process.env.REACT_APP_API_URL}/api/chat-sessions/${sessionId}`, {
194
  headers: {
195
  'Authorization': `Bearer ${authToken}`,
196
  'Content-Type': 'application/json'
 
214
  if (!currentSessionId || !authToken) return;
215
 
216
  try {
217
+ await fetch(`${process.env.REACT_APP_API_URL}/api/chat-sessions/${currentSessionId}/messages`, {
218
  method: 'POST',
219
  headers: {
220
  'Authorization': `Bearer ${authToken}`,
 
238
  if (!sessionId || !authToken) return;
239
 
240
  try {
241
+ await fetch(`${process.env.REACT_APP_API_URL}/api/chat-sessions/${sessionId}`, {
242
  method: 'PUT',
243
  headers: {
244
  'Authorization': `Bearer ${authToken}`,
 
268
  // Creating completely new chat with fresh context
269
  try {
270
  // Step 1: Reset memory session
271
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/new-chat`, {
272
  method: 'POST',
273
  headers: {
274
  'Authorization': `Bearer ${authToken}`,
 
402
 
403
  console.log('Sending message with session ID:', currentSessionId); // Debug log
404
 
405
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/chat-sequential`, {
406
  method: 'POST',
407
  headers: headers,
408
  body: JSON.stringify({
 
491
  setThinkingAdvisors([replyContext.persona_id]);
492
 
493
  try {
494
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/reply-to-advisor`, {
495
  method: 'POST',
496
  headers: {
497
  'Content-Type': 'application/json',
 
575
  setThinkingAdvisors([advisorId]);
576
 
577
  try {
578
+ const response = await fetch(`${process.env.REACT_APP_API_URL}/chat/${advisorId}`, {
579
  method: 'POST',
580
  headers: {
581
  'Content-Type': 'application/json',