1

the server

import app from "../firebase/firebaseCon";
import analytics from "../firebase/firebaseCon";
const express = require("express");

const ex = express();

ex.get("/store", (req, res) => {
  const store = [
    { id: 1, firstname: "hamdan" },
    { id: 1, firstname: "hamdan" },
    { id: 1, firstname: "hamdan" },
  ];
  res.json(store);
});

ex.listen(5000, () => {
  console.log("hello");
});


the firebase


import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
const firebaseConfig = {
  apiKey: "",
  authDomain: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: "",
};

export const app = initializeApp(firebaseConfig);
export const analytics = getAnalytics(app);

both of the codes above are in separate files whenever i try to require or import the firebase file into the server i get an error and the app stops not that much description in the error it only says that there is an internal error

the error

App.js:14          GET http://localhost:3000/store 500 (Internal Server Error)
componentDidMount @ App.js:14
commitLayoutEffectOnFiber @ react-dom.development.js:23305
commitLayoutMountEffects_complete @ react-dom.development.js:24688
commitLayoutEffects_begin @ react-dom.development.js:24674
commitLayoutEffects @ react-dom.development.js:24612
commitRootImpl @ react-dom.development.js:26823
commitRoot @ react-dom.development.js:26682
finishConcurrentRender @ react-dom.development.js:25981
performConcurrentWorkOnRoot @ react-dom.development.js:25809
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533

proxy problem

Could not proxy request /store from localhost:3000 to http://localhost:5000/.
SilentH11
  • 19
  • 7
  • can we see the error? – Orion447 Feb 15 '23 at 21:01
  • im new to firebase just wanted to get the data from there and print it in my website – SilentH11 Feb 15 '23 at 21:04
  • Makes sense we all have been there. I found this thread when googling your proxy error. I would go through the answers and report back. https://stackoverflow.com/questions/45367298/could-not-proxy-request-pusher-auth-from-localhost3000-to-http-localhost500 – Orion447 Feb 15 '23 at 21:42

1 Answers1

0

Change the express.listen from port 5000 to port 3000

Like so

ex.listen(3000, () => {
  console.log("hello");
});
Orion447
  • 351
  • 4
  • 16
  • i tried it didnt work i even tried more of the answers the problem im facing is kind of different cause im aiming to get the firebase and when ever i write the first two rows in the server file its stops – SilentH11 Feb 15 '23 at 21:53
  • import app and import analytics... importing them is what causes the problem – SilentH11 Feb 15 '23 at 21:54
  • the problem was that the server couldn't use import it only used require. but using require only on the files and not the function in them since non of the functions are defined as exports – SilentH11 Feb 16 '23 at 08:23