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/api-management/developer-portal-self-host.md
+25-40Lines changed: 25 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
---
2
-
title: Self-host the developer portal
2
+
title: Self-host the API Management developer portal
3
3
titleSuffix: Azure API Management
4
-
description: Learn how to self-host the API Management developer portal.
4
+
description: Learn how to self-host the developer portal for Azure API Management.
5
5
author: dlepow
6
6
ms.author: danlep
7
-
ms.date: 04/15/2021
7
+
ms.date: 06/07/2022
8
8
ms.service: api-management
9
9
ms.topic: how-to
10
10
---
11
11
12
12
# Self-host the API Management developer portal
13
13
14
-
This tutorial describes how to self-host the [API Management developer portal](api-management-howto-developer-portal.md). Self-hosting gives you flexibility to extend the developer portal with custom logic and widgets that dynamically customize pages on runtime. You can self-host multiple portals for your API Management instance, with different features. When you self-host a portal, you become its maintainer and you are responsible for its upgrades.
14
+
This tutorial describes how to self-host the [API Management developer portal](api-management-howto-developer-portal.md). Self-hosting gives you flexibility to extend the developer portal with custom logic and widgets that dynamically customize pages on runtime. You can self-host multiple portals for your API Management instance, with different features. When you self-host a portal, you become its maintainer and you're responsible for its upgrades.
15
15
16
16
The following steps show how to set up your local development environment, carry out changes in the developer portal, and publish and deploy them to an Azure storage account.
17
17
@@ -27,7 +27,7 @@ To set up a local development environment, you need to have:
27
27
- An Azure storage account with [the static websites feature](../storage/blobs/storage-blob-static-website.md) enabled. See [Create a storage account](../storage/common/storage-account-create.md).
28
28
- Git on your machine. Install it by following [this Git tutorial](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
29
29
- Node.js (LTS version, `v10.15.0` or later) and npm on your machine. See [Downloading and installing Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
1. If you'd like to enable CAPTCHA in your developer portal, see [Enable CAPTCHA](#enable-captcha).
106
+
1. If you'd like to enable CAPTCHA in your developer portal, set `"useHipCaptcha": true`. Make sure to [configure CORS settings for developer portal backend](#configure-cors-settings-for-developer-portal-backend).
107
107
108
108
### config.publish.json file
109
109
@@ -122,7 +122,7 @@ Configure the file:
122
122
123
123
1. Copy and paste the `managementApiUrl` and `managementApiAccessToken` values from the previous configuration file.
124
124
125
-
1. If you'd like to enable CAPTCHA in your developer portal, see [Enable CAPTCHA](#enable-captcha).
125
+
1. If you'd like to enable CAPTCHA in your developer portal, set `"useHipCaptcha": true`. Make sure to [configure CORS settings for developer portal backend](#configure-cors-settings-for-developer-portal-backend).
126
126
127
127
### config.runtime.json file
128
128
@@ -163,9 +163,9 @@ Configure the **Static website** feature in your storage account by providing ro
163
163
164
164
1. Select **Save**.
165
165
166
-
### Configure the CORS settings
166
+
### Configure CORS settings for storage account
167
167
168
-
Configure the Cross-Origin Resource Sharing (CORS) settings:
168
+
Configure the Cross-Origin Resource Sharing (CORS) settings for the storage account:
169
169
170
170
1. Go to your storage account in the Azure portal and select **CORS** from the menu on the left.
### Configure CORS settings for developer portal backend
185
+
186
+
Configure CORS settings for the developer portal backend to allow requests originating through your self-hosted developer portal. The self-hosted developer portal relies on the developer portal's backend endpoint (set in `backendUrl` in the portal configuration files) to enable several features, including:
187
+
188
+
* CAPTCHA verification
189
+
* [OAuth 2.0 authorization](api-management-howto-oauth2.md) in the test console
190
+
* [Delegation](api-management-howto-setup-delegation.md) of user authentication and product subscription
191
+
192
+
To add CORS settings:
193
+
194
+
1. Go to your API Management instance in the Azure portal, and select **Developer portal** > **Portal settings** from the menu on the left.
195
+
1. On the **Self-hosted portal configuration** tab, add one or more **Origin** domain values. For example:
196
+
* The domain where the self-hosted portal is hosted, such as `https://www.contoso.com`
197
+
* `localhost` for local development (if applicable), such as `http://localhost:8080` or `https://localhost:8080`
198
+
1. Select **Save**.
199
+
184
200
## Step 3: Run the portal
185
201
186
202
Now you can build and run a local portal instance in the development mode. In development mode, all the optimizations are turned off and the source maps are turned on.
@@ -404,37 +420,6 @@ The conversion process is almost identical to setting up a generic self-hosted p
404
420
> [!TIP]
405
421
> We recommend using a separate storage account in the `config.publish.json` file. This approach gives you more control and simplifies the management of the hosting service of your portal.
406
422
407
-
## Enable CAPTCHA
408
-
409
-
When setting up the self-hosted portal, you may have disabled CAPTCHA through the `useHipCaptcha` setting. Communication with CAPTCHA happens through an endpoint, which lets Cross-Origin Resource Sharing (CORS) happen for only the managed developer portal hostname. If your developer portal is self-hosted, it uses a different hostname and CAPTCHA won't allow the communication.
410
-
411
-
### Update the JSON config files
412
-
413
-
To enable the CAPTCHA in your self-hosted portal:
414
-
415
-
1. Assign a custom domain (for example, `api.contoso.com`) to the **Developer portal** endpoint of your API Management service.
416
-
417
-
This domain applies to the managed version of your portal and the CAPTCHA endpoint. For steps, see [Configure a custom domain name for your Azure API Management instance](configure-custom-domain.md).
418
-
419
-
1. Go to the `src` folder in the [local environment](#step-1-set-up-local-environment) for your self-hosted portal.
420
-
421
-
1. Update the configuration `json` files:
422
-
423
-
| File | New value | Note |
424
-
| ---- | --------- | ---- |
425
-
| `config.design.json`| `"backendUrl": "https://<custom-domain>"` | Replace `<custom-domain>` with the custom domain you set up in the first step. |
426
-
| | `"useHipCaptcha": true` | Change the value to `true` |
427
-
| `config.publish.json`| `"backendUrl": "https://<custom-domain>"` | Replace `<custom-domain>` with the custom domain you set up in the first step. |
428
-
| | `"useHipCaptcha": true` | Change the value to `true` |
429
-
| `config.runtime.json` | `"backendUrl": "https://<custom-domain>"` | Replace `<custom-domain>` with the custom domain you set up in the first step. |
430
-
431
-
1. [Publish](#step-5-publish-locally) the portal.
432
-
433
-
1. [Upload](#step-6-upload-static-files-to-a-blob) and host the newly published portal.
434
-
435
-
1. Expose the self-hosted portal through a custom domain.
436
-
437
-
The portal domain's first and second levels need to match the domain set up in the first step. For example, `portal.contoso.com`. The exact steps depend on your hosting platform of choice. If you used an Azure storage account, you can refer to [Map a custom domain to an Azure Blob Storage endpoint](../storage/blobs/storage-custom-domain-name.md) for instructions.
0 commit comments