awslabs / frontend-discovery

The aim of this project is to define and drive adoption of a frontend discovery pattern, with a primary focus on client-side rendered (CSR), server-side rendered (SSR) and edge-side rendered (ESR) micro-frontends
MIT No Attribution
147 stars 4 forks source link

How to register the very first version of a MFE via the Admin API #4

Closed VelinGeorgievGP closed 9 months ago

VelinGeorgievGP commented 9 months ago

Hey @lucamezzalira , guys,

I am playing with the solutions and I managed to successfully deploy it, however I struggle to register my very first version of a MFE via the Admin API.

I am following the API documentation and here are the steps I performed:

curl https://api.amazonaws.com/prod/projects/d7859c4c-77a2-4b49-a54d-0b407492a31e/microFrontends/5a23e420-1a6c-4ae2-ab94-eebdb3eafea9 -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" --request PATCH --data '{"name": "mfe-2","activeVersions":[{"version": "1.0.0","traffic": 100}],"default": "1.0.0"}' -H "Content-Type: application/json"

I am getting response

The specified version could not be found.

curl https://api.amazonaws.com/prod/projects/d7859c4c-77a2-4b49-a54d-0b407492a31e/microFrontends/17d12cd5-d7fa-4f80-a378-0e3ed20ef8f9/versions -H "Authorization: Bearer <TOKEN>" --request POST --data '{ "version": { "url": "https://static.example.com/my-account-1.0.0.js", "metadata": { "version": "1.0.0", "integrity": "e0d123e5f317bef78bfdf5a008837200" }, "fallbackUrl": "https://alt-cdn.com/my-account-1.0.0.js" }, "deploymentStrategy": "AllAtOnce" }' -H "Content-Type: application/json" 

but got the following error:

Unable to create deployment when no existing version is currently receiving 100% traffic.

curl https://api.amazonaws.com/prod/projects/d7859c4c-77a2-4b49-a54d-0b407492a31e/microFrontends -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" --request POST --data '{"name": "mfe-2","activeVersions":[{"version": "1.0.0","traffic": 100}]}'

However the MFE entry gets created in the table dropping the activeVersions property.

What am I doing wrong?

Thanks!

VelinGeorgievGP commented 9 months ago

All right, I got it working by dropping the 'deploymentStrategy' prop from the POST payload.

curl https://api.amazonaws.com/prod/projects/d7859c4c-77a2-4b49-a54d-0b407492a31e/microFrontends/17d12cd5-d7fa-4f80-a378-0e3ed20ef8f9/versions -H "Authorization: Bearer <TOKEN>" --request POST --data '{ "version": { "url": "https://static.example.com/my-account-1.0.0.js", "metadata": { "version": "1.0.0", "integrity": "e0d123e5f317bef78bfdf5a008837200" }, "fallbackUrl": "https://alt-cdn.com/my-account-1.0.0.js" } }' -H "Content-Type: application/json" 

Cheers,