Tuesday, June 11, 2024

Resolving Multiple HTTPS Entries in Sitemap

Issue Observed:

Recently, I encountered an issue where multiple HTTPS entries were appearing in the sitemap.


Solution:

The fix was straightforward. The problem was due to an incorrect setting under:

Site /sitecore/content/Site/Settings/Site Grouping/Site1

Target Hostname:

The issue was resolved by removing the https from the target hostname.

With this adjustment, the sitemap no longer displayed multiple HTTPS entries.







Thursday, May 2, 2024

How to cleanup the resource file

 Run below command to setup Extensibility

 dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.ResourcePackage --version 5.2.113

If you find any issue check your latest installed packages

dotnet sitecore plugin list
Cleanup command
dotnet sitecore itemres cleanup --what-if


Other Commands
dotnet sitecore ser push -n "Local"   
npm run start:connected
npm run lint -- --fix 

More details - https://doc.sitecore.com/xp/en/developers/104/developer-tools/the-cli-login-command.html#options

Tuesday, April 30, 2024

Sitecore Search - Crawler error and fix

During the crawler setup, I got below error 



Fix, some pages missing OG details, make sure your meta data is placed properly on all pages


    • Missing Fields: type
    • Required Fields: type, id
Some pages are showing 404, so published those pages

If you check the attributes, these two are by default mandatory field in the schema




to fix this issue, provide the fix type value in Search or add the attribute selector to get the value from the pages.

Tuesday, April 16, 2024

Troubleshooting Sitecore XM Cloud: Deployment Process Halted with Status Code 409 - Project and Environment Already in Deployment.

Lately, during the construction and deployment of the UAT environment, all builds were stuck in the queue and failed to respond. Despite numerous attempts to delete the builds, the issue persisted.



After posting about the problem in the Slack channel, we were unable to find a definitive solution. Consequently, we raised a Sitecore ticket, seeking assistance with the issue.


Slack Posted Question - I'm currently encountering an issue with deploying a build on the UAT environment. Despite waiting for several hours, the build remains stuck in the queue.


After canceling the build and attempting to restart the environment, it' showing an message  that the build is still running and it's preventing the restart.

Now, every build is getting queued up. Do we have any options available to resolve this issue? the same branch was successfully deployed to a different environment (Dev) without any issues.

I would greatly appreciate it if anyone who has experienced a similar problem could share their suggestions.

Console error was 

{

    "title": "Not Found",

    "status": 404,

    "detail": "Deployment entity not existing for deploymentId XXXXXXXXXX",

    "traceId": "XXXXXXXXXXXXXXXXXX"

}


There was an issue with our service connection, due to which environment was wrongfully marked as having a running deployment, got fix now.

Slack Reference -  Slack Conversation Link


Tuesday, April 2, 2024

Resolving "Unable to Connect to the Remote Server" in PowerShell with Docker

Recently, I encountered an issue while working on a project that involved PowerShell and Docker. The error message was:

Waiting for CM to become available...

Invoke-RestMethod : Unable to connect to the remote server

At C:\Projects\Project.Web\up.ps1:121 char:19

+ ...   $status = Invoke-RestMethod "http://localhost:8079/api/http/routers ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Fix - Issue got fix with below steps


This error indicated that my PowerShell script could not connect to the server at http://localhost:8079/api/http/routers, which was crucial for the project's functionality. After some investigation, I discovered that the problem was related to the Docker network configuration.


Here is how I resolved the issue:


Step-by-Step Solution

List Docker Networks:

First, I needed to identify the existing Docker networks. This can be done using the following command:

docker network ls

This command lists all the networks created by Docker. The output should look something like this:


NETWORK ID          NAME                DRIVER              SCOPE

9b73baa9dff4        bridge              bridge              local

2c2b1a85c1a2        host                host                local

3e8e8a1c32b4        none                null                local

7e8f1b1d3f44        my_project_network  bridge              local

Remove the Project Network:

After identifying the network associated with my project, I removed it using the following command:



docker network rm <name_of_network>

For example, if the network name was my_project_network, the command would be:


docker network rm my_project_network


Run the up.psl script again


If you have any further questions or run into additional issues, feel free to leave a comment or reach out. Happy coding!

Wednesday, February 7, 2024

Sitecore XM Cloud - Fixing URL Redirections in Next.js on Vercel Using vercel.json

When URLs don't redirect correctly, it can be frustrating. Recently, we faced this challenge in our Next.js app on Vercel. Let's walk through how we tackled it.

Our URLs containing spaces or special characters weren't redirecting properly on Vercel. This glitch disrupted our users' flow and needed fixing ASAP.

Exploring Solutions:

At first, we tried a JavaScript-based approach within our app code. It worked fine locally but didn't cut it on Vercel.

Leveraging vercel.json:

Next, we discovered Vercel's powerful vercel.json file. With it, we could define redirect rules to map old URLs to new ones. Simple yet effective!

Crafting the Solution:

We created a vercel.json file with rewrite rules. These rules told Vercel how to handle URLs with spaces or special characters, ensuring they redirected correctly.


Sample vercel.json Code:


{
    "rewrites": [
      {        
        "source": "/(.*)%20(.*)",
        "destination": "/$1-$2"
      },
      {        
        "source": "/(.*)\\s(.*)",
        "destination": "/$1-$2"
      }
    ]
  }
 

Deployment and Validation:

After updating the vercel.json file, we deployed our Next.js app on Vercel. Through testing, we confirmed that our URLs now redirected smoothly, no more hiccups!

Conclusion:

In our journey to fix URL redirection issues, we learned the power of vercel.json. By leveraging its capabilities, we resolved our problem and improved our users' experience. It's a reminder that sometimes, simple solutions are the best.

Tuesday, January 2, 2024

Essential Git Commands for Efficient Version Control Management

Cleanup all local branches except master

for /f "delims=" %i in ('git branch ^| findstr /v "develop"') do git branch -D %i

Other basic commands

Merge Latest develop Branch into Current Branch

git checkout develop
git pull origin develop
git checkout <your-current-branch>
git merge develop

Create a New Branch

git checkout -b new-branch-name

Switch to an Existing Branch

git checkout existing-branch-name

Delete a Local Branch

git branch -d branch-name

Delete a Remote Branch

git push origin --delete branch-name

View Commit History

git log

View Branches


git branch -a

Stage All Changes for Commit

git add .

Commit Changes

git commit -m "Your commit message"

Push Changes to Remote Repository

git push origin branch-name

Pull Changes from Remote Repository

git pull origin branch-name

Rebase Current Branch onto Another Branch

git checkout your-branch
git rebase branch-to-rebase-onto

Stash Changes

git stash

Apply Stashed Changes

git stash apply