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

[nextjs][react][vue][angular] Add support for layout service REST configuration name #1527

Conversation

orioltf
Copy link
Contributor

@orioltf orioltf commented Jun 15, 2023

Description / Motivation

This PR adds support to define what Layout Service configuration name should be used for REST calls to Layout Service in Next.js, React, Vue and Angular packages:

  • It adds a new CONFIGURATION_NAME environment variable, which by default holds the value default
  • It consumes the new variable in the config-generator and adds a new property in the returned configuration object
  • It consumes the new configurationName config property in the layout-service-factory to configure the RestLayoutService

REST calls to layout service can have multiple configurations in Sitecore. The linked documentation also exposes a configuration named jss.

However, the RestLayoutService has hard-coded that the configuration name has to be default, which contradicts (IMHO) the provided example in the documentation.

Testing Details

Prerequisits

  • A deployed Sitecore instance with:
    • a headless topology
    • a custom LayoutService configuration named jss (for instance)
  • A JSS project with Next.js flavour with:
    • proper configuration to be able to connect to the above mentioned Sitecore instance
    • DEBUG environment variable set to sitecore-jss:*
    • run jss start:connected

Test case

  • Load the reported URL where Next.js can be reached in the browser (http://localhost:3000 by default)
  • Check the call that Next.js makes to the layout service: it's path ends with /default.

When the default layout service configuration is not configured, miss configured, or configured in a special dedicated way, it may not return the sitecore.route object in the response, which causes the default assumptions from the routing in JSS frontend to fail and therefor to error.

  • Unit Test Added
  • Manual Test/Other (Please elaborate)
    Tested manually as reported in the Testing Details section

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

orioltf added 4 commits June 15, 2023 10:33
This variable holds the name of the configuration name that should be used in REST requests to layout service
…fig-generator to expose it in the `config` object
@orioltf orioltf changed the title Add support for layout service REST configuration name [nextjs][react][vue][angular] Add support for layout service REST configuration name Jun 15, 2023
@illiakovalenko
Copy link
Contributor

@orioltf Thank you for your contribution! Our team appreciates that!
For your information, for simplicity, I pulled changes from your PR, created another one #1543, and added some minor changes and improvements. So, I close this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants