mirror of
https://github.com/gosticks/web.git
synced 2026-12-03 17:51:39 +00:00
Use the proxy feature to simplify API calls during development
See https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"homepage": "/admin",
|
||||
"proxy": "http://pi.hole",
|
||||
"devDependencies": {
|
||||
"faker": "^4.1.0",
|
||||
"gulp": "^3.9.1",
|
||||
|
||||
+3
-5
@@ -153,12 +153,10 @@ export const api = {
|
||||
let apiLocation;
|
||||
|
||||
if(config.fakeAPI)
|
||||
apiLocation = window.location.host + process.env.PUBLIC_URL + "/fakeAPI";
|
||||
else if(config.developmentMode)
|
||||
apiLocation = "pi.hole/admin/api";
|
||||
apiLocation = process.env.PUBLIC_URL + "/fakeAPI";
|
||||
else
|
||||
apiLocation = window.location.hostname + (window.location.port ? ':' + window.location.port : '') + "/admin/api";
|
||||
apiLocation = "/admin/api";
|
||||
|
||||
return window.location.protocol + "//" + apiLocation + "/" + endpoint;
|
||||
return apiLocation + "/" + endpoint;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user