This project, sample-react-app
, is a modern, responsive front-end application built using Vite and Next UI for React. It's designed to connect to a custom weather API to fetch and display weather data dynamically.
- Modern React UI: Utilizes React 18 for component-based architecture.
- Styling with Next UI: Offers a rich set of UI components for building intuitive interfaces.
- Responsive Design: Ensures the app looks great on both desktop and mobile devices.
- Weather API Integration: Connects to a custom-built weather API to display real-time weather data.
Before you begin, ensure you have the following installed:
- Node.js (v14 or later)
- npm/yarn
To set up the project locally, follow these steps:
-
Open in Codespaces or clone repository:
git clone https://github.com/CDT-UEL/sample-react-app cd sample-react-app
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
Visit
http://localhost:3000
to view the app.
The frontend app is designed to work with the weather_API
built in week 3 with Express. However, your browser will throw a cors polity error. To address that we must install cors and use it in the server.ts
file as follows:
-
Open the weather_api in Codespaces or locally.
-
Run the following command in the terminal to install cors:
npm install cors
-
Enable CORS in your Express application by adding the following to your
server.ts
:import cors from "cors"; app.use(cors());
-
Ensure the backend server is running and accessible by running:
npm run build npm run start
-
Modify the frontend app's API request URLs to point to your weather API endpoints. In the
src/api/actions.ts
file, update theAPI_URL
to your server's address:API_URL = "http://localhost:5000";
For detailed information on the weather API endpoints, parameters, and responses, refer to the week 3 tutorial and the Weather API Documentation.
This project is licensed under the MIT License - see the LICENSE file for details.
For any queries or further assistance, please contact Lucian Duta.