Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V14: Allowing custom backoffice host with CORS policy #15269

Merged
merged 2 commits into from Nov 21, 2023

Conversation

elit0451
Copy link
Member

@elit0451 elit0451 commented Nov 21, 2023

Details

  • Allows the backoffice to run from a different host than the API host if BackOfficeHost setting is configured:
    • by adding a CORS policy for the custom backoffice host - it respects the middleware order (placed after UseRouting(), but before UseAuthorization())

Test

Setup:

  • In Umbraco.Web.UI.New.Client project create a file .env.local and add the following contents:
VITE_UMBRACO_USE_MSW=off # on = turns on MSW, off = disables all mock handlers
VITE_UMBRACO_API_URL=https://localhost:44339
VITE_UMBRACO_INSTALL_STATUS=running # running or must-install or must-upgrade
VITE_MSW_QUIET=off # on = turns off MSW console logs, off = turns on MSW console logs
VITE_UMBRACO_EXTENSION_MOCKS=off # on = turns on extension mocks, off = turns off extension mocks
  • Run the npm install, npm run dev into the client project;
  • Add the following NewBackOffice setting to your appsettings.json (Umbraco.Web.UI.New project):
"Umbraco": {
    "CMS": {
        "NewBackOffice":{
            "BackOfficeHost": "http://localhost:5173",
            "AuthorizeCallbackPathName": "/"
        },
        . . .

Test:

  • Run new Backoffice project: Umbraco.Web.UI.New;
  • Go to http://localhost:5173 which will redirect to https://localhost:44339 for authentication and then redirect back to http://localhost:5173;
  • Verify that there are no CORS errors in the dev tools.

@elit0451 elit0451 added the project/bellissima AKA "the new backoffice" label Nov 21, 2023
@kjac kjac self-requested a review November 21, 2023 11:34
Copy link
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and tests great too 👍

@elit0451 elit0451 merged commit 42dd2da into v14/dev Nov 21, 2023
13 checks passed
@elit0451 elit0451 deleted the v14/feature/cors-for-custom-backoffice-host branch November 21, 2023 14:49
@iOvergaard iOvergaard removed the project/bellissima AKA "the new backoffice" label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants