Skip to content

Commit bfd7ce9

Browse files
authored
fix: geocoder demo on windows #1140 (#1177)
* fix: path to run properly on windows (#1140) * fix: readme instructions + redirect uri (https)
1 parent 2323340 commit bfd7ce9

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

demos/geocoder-browser/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Running this demo
22

3-
1. Make sure you run `npm run bootstrap` in the root folder to setup the dependencies
3+
1. Make sure you run `npm run build` in the root folder to setup the dependencies
44
2. Register a new app on https://developers.arcgis.com
5-
3. Add a redirect URL of `http://localhost:8080/post-sign-in.html` to your app.
5+
3. Add a redirect URL of `https://localhost:8080/authenticate.html` to your app.
66
4. Copy the `config.js.template` file, rename it to `config.js`
77
5. Copy your apps client id into your new `config.js` file.
88
6. `npm start`
9-
7. Visit http://localhost:8080 and click "Sign In" to start the OAuth 2.0 process.
9+
7. Visit https://localhost:8080 and click "Sign In" to start the OAuth 2.0 process.
1010
8. Start clicking buttons to send off authenticated geocoding requests.
1111

1212
**Note:** The server starts with a special configuration to serve URLs starting with `@esri/arcgis-rest-*` from their respective packages. In your application you will need to change these URLs to point to their respective locations.

demos/geocoder-browser/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h1>get to geocodin!</h1>
5555
authBtn.addEventListener('click', function (e) {
5656
arcgisRest.ArcGISIdentityManager.beginOAuth2({
5757
clientId: ClientId,
58-
redirectUri: "http://localhost:8080/authenticate.html",
58+
redirectUri: "https://localhost:8080/authenticate.html",
5959
popup: true,
6060
portal: "https://www.arcgis.com/sharing/rest"
6161
}).then((session) => {

scripts/get-package-json.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { readFile } from "fs/promises";
22
import { globby } from "globby";
33
import pkgDir from "pkg-dir";
4-
import { join, dirname } from "path";
4+
import { posix } from "path";
5+
import { fileURLToPath } from "url";
56

6-
const __dirname = dirname(new URL(import.meta.url).pathname);
7+
const __dirname = fileURLToPath(new URL('.', import.meta.url)).replace(/\\/g, '/');
78

89
/**
910
* Returns an object like:
@@ -15,8 +16,10 @@ const __dirname = dirname(new URL(import.meta.url).pathname);
1516
* For all packages in the packages/* folder.
1617
*/
1718
export default async function getPackages() {
18-
const rootDir = await pkgDir(__dirname);
19-
const packageFiles = await globby(join(rootDir, "packages/*/package.json"));
19+
const rootDir = (await pkgDir(__dirname)).replace(/\\/g, "/");
20+
21+
const packageFiles = await globby(posix.join(rootDir, "packages/*/package.json"));
22+
2023
return Promise.all(
2124
packageFiles.map((pkgPath) => {
2225
return readFile(pkgPath).then((pkg) => {

scripts/run-demo-server.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import browserSync from "browser-sync";
2-
import { join, resolve, dirname } from "path";
2+
import { resolve, posix } from "path";
3+
import { fileURLToPath } from "url";
34
import getPackages from "./get-package-json.js";
45

56
(async () => {
67
const cwd = process.cwd();
78
const packages = await getPackages();
8-
const __dirname = dirname(new URL(import.meta.url).pathname);
9+
const __dirname = fileURLToPath(new URL('.', import.meta.url)).replace(/\\/g, '/');
910
const packageFolders = packages.map(({ name }) => {
1011
return {
1112
route: `/${name}`,
12-
dir: resolve(join(__dirname, "../", "node_modules", name))
13+
dir: resolve(posix.join(__dirname, "../", "node_modules", name))
1314
};
1415
});
1516

0 commit comments

Comments
 (0)