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
Copy file name to clipboardExpand all lines: articles/static-apps/local-development.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,25 +150,27 @@ Depending on whether or not your application is built with a JavaScript framewor
150
150
151
151
### Environment configuration files
152
152
153
-
If you are building your app with front-end frameworks that have a CLI, use environment configuration files. In the development configuration file, you can specify the path to the API, which points to the local location of `http:127.0.0.1:7071`.
153
+
If you are building your app with front-end frameworks that have a CLI, you should use environment configuration files. Each framework or library has a different way of handling these environment configuration files. It's common to have a configuration file for development that is used when your application is running locally, and one for production that is used when your application is running in production. The CLI for the JavaScript framework or static site generator that you are using will automatically know to use the development file locally and the production file when your app is built by Azure Static Web Apps.
154
+
155
+
In the development configuration file, you can specify the path to the API, which points to the local location of `http:127.0.0.1:7071` where the API for your site is running locally.
154
156
155
157
```
156
158
API=http:127.0.0.1:7071/api
157
159
```
158
160
159
-
Alternatively, the production configuration specifies the path to the API as `api`.
161
+
In the production configuration file, specify the path to the API as `api`. This way your application will call the api via "yoursite.com/api" when running in production.
160
162
161
163
```
162
164
API=api
163
165
```
164
166
165
-
This environment variable is then referenced in the web app's JavaScript.
167
+
These configuration values can be referenced as Node environment variables in the web app's JavaScript.
166
168
167
169
```js
168
170
let response =awaitfetch(`${process.env.API}/message`);
169
171
```
170
172
171
-
When the application is built with its CLI, the `process.env.API` value is replaced with the value from the appropriate configuration file.
173
+
When the CLI is used to run your site in development mode or to build the site for production, the `process.env.API` value is replaced with the value from the appropriate configuration file.
172
174
173
175
For more information on configuring environment files for front-end JavaScript frameworks and libraries, see these articles:
174
176
@@ -197,4 +199,4 @@ For more information on configuring environment files for front-end JavaScript f
0 commit comments