Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Answered

E-commerce React props.context.app returns {"config":{},"routes":{}} even though app.settings.json has content

Posted on by 5

Hi, I set up a local project using the https://github.com/microsoft/Msdyn365.Commerce.Online starter project. I have content in the app.settings.json file, however when I access the "app" property inside of props.context, both the "config" and "routes" are empty objects. Has anyone else experienced this? Is there a trick to expose this info?

I am on {"sdkVersion":"1.43.3","sskVersion":"9.40.24","retailServerProxyVersion":"9.40.1","node_runtime_version":"16"}

Steps taken to debug "props.context.app" returning "app: { config: {}, routes: {} }"

Ran "yarn build" to copy the latest "settings/app.settings.json" file into the build folder
I have read learn.microsoft.com/.../app-settings
I have tried Googling but not many links, only thing is pointing back to msdyn365 docs which I have read

  • Ken Walton Profile Picture
    Ken Walton 5 on at
    RE: E-commerce React props.context.app returns {"config":{},"routes":{}} even though app.settings.json has content

    Thank you Brady! This is what I needed to learn.

  • Verified answer
    Brady Deal Profile Picture
    Brady Deal on at
    RE: E-commerce React props.context.app returns {"config":{},"routes":{}} even though app.settings.json has content

    Hey Ken,

    First off adding the modules segment will never give you the app context since at that point you are rendering the module on its own.  

    What you need to do is create a mock page, which will give you the appContext, which you can change at anytime.  app.Settings.json is just the schema, the actual values are stored in the mock page or in SiteBuilder itself.

    Brady  

  • Ken Walton Profile Picture
    Ken Walton 5 on at
    RE: E-commerce React props.context.app returns {"config":{},"routes":{}} even though app.settings.json has content

    Hi Brady,

    I appreciate your help. I had been trying to access the props.context.app properties inside of a component module and the config and routes would always be empty objects, even though in the app.settings.json (locally) there is lots of stuff.

    Now I tried running the console command you provided when visiting the index page and then in a module preview.

    https://localhost:4000/ will show config and routes with lots of properties inside of them, but not what I have in local app.settings.json, probably what is on actual live dev site that my env file points to. Does this sound right?

     localhost:4000/ [when I paste as url, and save post, it is truncated] modules?type=helloworld will show config {} and routes {} as empty objects.

    ---

    Update:

    I cloned new instance of https://github.com/microsoft/Msdyn365.Commerce.Online and did not update the .env file. Testing the preview localhost:4000/modules for the helloworld module returned negative result, same when testing default page mock https://localhost:4000/page?mock=default-page.

    After the above, I added the info to the .env file, ran  the page mock for default page and the preview for hello world and both returned config and routes as empty objects.

    But pointing browser to index page of https://localhost:4000/ and ___initialData___.requestContext.app in console window shows config, routes, contentSecurityPolicy, and platform all populated with values from remote dev server.

    I had expected to always see the local app.settings.json values, whether in a page, container, or content component. I am new to D365 (1 week with only training from the documentation on learn.microsoft.com/.../commerce-architecture)

  • Brady Deal Profile Picture
    Brady Deal on at
    RE: E-commerce React props.context.app returns {"config":{},"routes":{}} even though app.settings.json has content

    Hey Ken,

    Where exactly are you trying to access these props?  Also are they always empty objects or do they eventually get filled in?  BTW I was not able to reproduce this, if I drop a breakpoint in a module in the starter project it returns me everything in appsettings.  The other thing to check is to type ___initialData___.requestContext.app in the console window to see if it is being returned.

    Brady

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans