Skip to content

This project sets up a local proxy server to make production data available locally without encountering CORS and similar issues. It uses an Express server to fetch data from the production API and serves it locally. Additionally, browser-sync is used to proxy the local server, making it accessible from a specific domain.

Notifications You must be signed in to change notification settings

tennisfar/prod-to-local-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Prod to local API

Description

This project sets up a local proxy server to make production data available locally without encountering CORS and similar issues. It uses an Express server to fetch data from the production API and serves it locally. Additionally, browser-sync is used to proxy the local server, making it accessible from a specific domain.

Execution

  1. Run the combined script to start both the Express server and browser-sync:
    npm start
  2. Access the available endpoints served locally from:
    https://web.develop.danskespil.dk:1337
    
    This page will display a list of all available endpoints, including the "lobby" endpoint and any future endpoints.

Usage

To use the endpoint in your code, you can create a function like this:

export const getLobbyData = async () => {
  return await ApiRequest({ url: 'https://web.develop.danskespil.dk:1337/dli/scapi/danskespil/gamevendorgvc/lobby' });
};

Troubleshooting

If the port is wrong, try killing all stuck or running localhosts:

npm run reset

About

This project sets up a local proxy server to make production data available locally without encountering CORS and similar issues. It uses an Express server to fetch data from the production API and serves it locally. Additionally, browser-sync is used to proxy the local server, making it accessible from a specific domain.

Topics

Resources

Stars

Watchers

Forks