You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) and
4
4
customized to route `/api` requests to external middleware -
@@ -14,43 +14,34 @@ specifically, the InfluxData `iot-app-<js, python, etc.>` example applications.
14
14
yarn dev
15
15
```
16
16
17
-
2. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
17
+
By default, the server runs on port `:3000`; otherwise, the next available port (for example, `3001`).
18
+
Visit [http://localhost:3000](http://localhost:3000) in your browser to see the result.
18
19
19
-
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
20
+
To view the IoT Starter device dashboard, visit [http://localhost:3000/devices/](http://localhost:3000/devices/)
20
21
21
-
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
22
+
1. To customize the UI default page, edit the `pages/index.tsx` file. The page auto-updates as you edit the file.
23
+
24
+
Next.js provides a sample REST API at [http://localhost:3000/api/hello](http://localhost:3000/api/hello). To customize the sample endpoints, edit `pages/api/hello.ts`.
25
+
26
+
View IoT Starter devices at [http://localhost:3000/devices/](http://localhost:3000/devices/).
27
+
To customize the device pages, edit the files located in [`./pages/devices`](./pages/devices/).
22
28
23
29
## Use with `iot-api-[language]` apps
24
30
25
31
To use the UI with one of the `iot-api-[language]` example apps, set `API_URL` in `./.env.development` to the URL of the API example app.
26
32
27
-
`iot-api-ui` uses a Next.js _catch-all_ route and `http-proxy` to proxy all `/api` requests to your API middleware server.
28
-
See `./pages/api/[...path].js` for the `/api` route and proxy configuration.
29
-
30
-
```js
31
-
importhttpProxyfrom'http-proxy'
32
-
33
-
/** Set API_URL to the URL of iot-api-js, iot-api-python, etc. **/
34
-
constAPI_URL=process.env.API_URL
35
-
constproxy=httpProxy.createProxyServer()
36
-
/** Don't parse JSON bodies on the proxied route **/
The UI automatically routes all `/api/` requests to your API server.
34
+
`iot-api-ui` uses Next.js' _catch-all_ routing and [**`rewrites`** module](https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites) to act as a proxy for cross-domain requests to the server.
35
+
To customize the URL rewrites, edit `next.config.js`.
46
36
47
37
## Learn More
48
38
39
+
Follow step-by-step tutorials to build the IoT Starter app:
40
+
41
+
-[InfluxDB OSS v2 Python and JavaScript tutorials](https://docs.influxdata.com/influxdb/v2/api-guide/tutorials/)
42
+
-[InfluxDB Cloud v2 Python and JavaScript tutorials](https://docs.influxdata.com/influxdb/cloud/api-guide/tutorials/)
43
+
49
44
To learn more about Next.js, see following resources:
50
45
51
46
-[Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
52
47
-[Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
53
-
54
-
## Credits
55
-
56
-
1.https://maxschmitt.me/posts/next-js-api-proxy/ for the `http-proxy` configuration.
0 commit comments