Skip to content

Commit acf0d46

Browse files
author
Taylor Payne
authored
chore: Make example app compatible with a tutor dev environment (#819)
* chore: update dev ports to be compatible with tutor dev * chore: update dev hosts from localhost to local.openedx.io * docs: explain a way to overcome CORS issue in example app * fixup! docs: explain a way to overcome CORS issue in example app
1 parent 7f0dce7 commit acf0d46

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

.env.development

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
EXAMPLE_VAR=Example Value
22
ACCESS_TOKEN_COOKIE_NAME=edx-jwt-cookie-header-payload
3-
ACCOUNT_PROFILE_URL=http://localhost:1995
4-
ACCOUNT_SETTINGS_URL=http://localhost:1997
5-
BASE_URL=http://localhost:8080
6-
CREDENTIALS_BASE_URL=http://localhost:18150
3+
ACCOUNT_PROFILE_URL=http://apps.local.openedx.io:1995/profile
4+
ACCOUNT_SETTINGS_URL=http://apps.local.openedx.io:1997/account
5+
BASE_URL=http://local.openedx.io:8080
6+
CREDENTIALS_BASE_URL=http://credentials.local.openedx.io:8150
77
CSRF_TOKEN_API_PATH=/csrf/api/v1/token
8-
DISCOVERY_API_BASE_URL=http://localhost:18381
9-
PUBLISHER_BASE_URL=http://localhost:18400
10-
ECOMMERCE_BASE_URL=http://localhost:18130
8+
DISCOVERY_API_BASE_URL=http://discovery.local.openedx.io:8381
9+
PUBLISHER_BASE_URL=http://apps.local.openedx.io:8400/publisher
10+
ECOMMERCE_BASE_URL=
1111
LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
12-
LEARNING_BASE_URL=http://localhost:2000
13-
LMS_BASE_URL=http://localhost:18000
14-
LOGIN_URL=http://localhost:18000/login
15-
LOGOUT_URL=http://localhost:18000/logout
16-
STUDIO_BASE_URL=http://localhost:18010
17-
MARKETING_SITE_BASE_URL=http://localhost:18000
18-
ORDER_HISTORY_URL=http://localhost:1996/orders
19-
REFRESH_ACCESS_TOKEN_ENDPOINT=http://localhost:18000/login_refresh
12+
LEARNING_BASE_URL=http://apps.local.openedx.io:2000
13+
LMS_BASE_URL=http://local.openedx.io:8000
14+
LOGIN_URL=http://local.openedx.io:8000/login
15+
LOGOUT_URL=http://local.openedx.io:8000/logout
16+
STUDIO_BASE_URL=http://studio.local.openedx.io:8001
17+
MARKETING_SITE_BASE_URL=http://local.openedx.io:8000
18+
ORDER_HISTORY_URL=
19+
REFRESH_ACCESS_TOKEN_ENDPOINT=http://local.openedx.io:8000/login_refresh
2020
SEGMENT_KEY=''
21-
SITE_NAME=localhost
21+
SITE_NAME=local.openedx.io
2222
USER_INFO_COOKIE_NAME=edx-user-info
2323
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
2424
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Describe what this pull request changes, and why. Include implications for peopl
44

55
**Merge checklist:**
66

7-
- [ ] Consider running your code modifications in the included example app within `frontend-platform`. This can be done by running `npm start` and opening http://localhost:8080.
7+
- [ ] Consider running your code modifications in the included example app within `frontend-platform`. This can be done by running `npm start` and opening http://local.openedx.io:8080.
88
- [ ] Consider testing your code modifications in another local micro-frontend using local aliases configured via [the `module.config.js` file in `frontend-build`](https://github.com/openedx/frontend-build#local-module-configuration-for-webpack).
99
- [ ] Verify your commit title/body conforms to the conventional commits format (e.g., `fix`, `feat`) and is appropriate for your code change. Consider whether your code is a breaking change, and modify your commit accordingly.
1010

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies based on this new package file. Delete `node_modules`, and run `npm
4141

4242
1. `npm install`
4343
2. `npm start`
44-
3. Open http://localhost:8080 to view the example app.
44+
3. Open http://local.openedx.io:8080 to view the example app.
4545

4646
## Architecture
4747

@@ -149,6 +149,19 @@ When making changes to frontend-platform, be sure to manually run the included e
149149

150150
If you want to test changes to frontend-platform against a micro-frontend locally, follow the directions here: https://github.com/openedx/frontend-build#local-module-configuration-for-webpack
151151

152+
## Getting the example app to work with a tutor dev environment
153+
154+
Part of the example app functionality includes an API request to get the logged in user's profile information. This request will fail by default due to CORS restrictions. To overcome this, patch `openedx-lms-development-settings` with the following settings (via a tutor plugin):
155+
156+
```python
157+
# Used for the example app in the frontend-plugin library
158+
CORS_ORIGIN_WHITELIST.append("http://local.openedx.io:8080")
159+
LOGIN_REDIRECT_WHITELIST.append("local.openedx.io:8080")
160+
CSRF_TRUSTED_ORIGINS.append("http://local.openedx.io:8080")
161+
```
162+
163+
Make sure the plugin is installed, enabled, and then run `tutor dev restart lms` to make sure the new configuration is picked up.
164+
152165
# Production Deployment Strategy
153166

154167
For any MFE built on top of the frontend-platform, the deployment strategy will be something like the following:

webpack.dev.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ module.exports = createConfig('webpack-dev', {
1414
'@edx/frontend-platform': path.resolve(__dirname, 'src'),
1515
},
1616
},
17+
devServer: {
18+
allowedHosts: ['.local.openedx.io'],
19+
},
1720
});

0 commit comments

Comments
 (0)