#medusa-plugin-strapi sync data medusa-strapi
274 messages · Page 1 of 1 (latest)
Hi I upgraded to the new verson, but still get the error " [STRAPI] 23-09-05 21:00:16 info : attempting to sync connect with medusa server on http://127.0.0.1:9000/strapi/hooks/seed
[STRAPI] 23-09-05 21:00:16 error : unable to send message to medusa server Request failed with status code 400
attempting to create medusa user"
Can you share your medusa log?
And the strapi log plz
do you have any idea?
Have you configured all the jwt keys and secrets
yes, I used "openssl rand -base64 32" to create secrets for each APP_KEYS, API_TOKEN_SALT, ADMIN_JWT_SECRET and JWT_SECRET. For the MEDUSA_STRAPI_SECRET, I made it the same as JWT Secret on Medusa.
Just making sure I am on right track. After cloning the repo, add env variables and run yarn install in medusa-strapi folder. Then run yarn build in the root of the repo.
On Medusa, I installed "medusa-plugin-strapi-ts", and in the strapiOptions, I enabled "auto_start". After the strapi run, I run the Medusa.
Yes perfect
Can you try pulling the master branch again
We pushed a couple of fixes today
yes thank you. will let you know
Hi I tried but the error stil lthere
Plz share the logs
it is exactly the same thing I shared above
Have you configured medusabackend url in strPi?
You need install.medusa-plugin-strapi-TS
yes, on Strapi, MEDUSA_BACKEND_URL=http://127.0.0.1:9000
here is what looks like on Medusa
i set the Strapi_secret and public key t o be the same as Medusa JWT Secret
after running Strapi the first time, I went to Strapi and created a User with the Role of Medusa and added it username, password too Strapi_Medusa_User env on Medusa
awesome, lol clear the error
so I think we should update this text in Readme, I was confused on this, thought have to create a user according to the tutorial
Also just wondering if this is possible to deploy on Azure
or you do you have any recommedation for hosting
Glad it worked..happy to accept a pr for the same
I am new to Docker and stuff like that. Just wondering do I need to put the whole repo on, or just the medusa-strapi folder
for sure
Only medusa strapi folder
dont need medusa-pugin-strapi-ts, and stuff like that? just curious, like on local we have to run yarn build at the root repo, looks like it connecting all folders together? so we deploy, we only need the medusa-strapi folder on GitHub and deploy right
You can load the full repo also
Whatever you do locally should work on the cloud
But on thr cloud i recommend using docker
Coz any deployment environment will ask which folder do you want to deploy
awesome, so for deployment, only the medusa-strapi folder is fine, and the docker file is taking care of everything else, and it will run normally right.
Do I have to change anything in the Docker
Only setup environment variables
awesome. thank you so much
Your welcome
it should be setup in the Dockerfile right
No
just in the env file? so dont have to do anything in Dockerfile? I see there is one dockerfile and dockerfile.prod
can you give an example? I am trying t deploy on Railway website it is saying "Railway doesn't support docker compose at the moment." does it affect anything
You don't docker compose on railway
Just load the repo on railway
Set the folder to medusa-strapi
And set all the environment varables
You could use the raw editor on railway to copy paste from your local to railway
Railway will detect the dockerfile
When you specify the folder
And start setting up
oh i see i thought you said have to add the env in Docker, so just add env variable in Railway work right
and should run the Dockerfile.prod s right
Railway runs the dockerfile
To be honest I have not tested the dockerfile.prod completely
The dockerfile works not sure about docketfile.prod
You can try it out and let me know
i got these errors
I dont set up AWS so I can remove thse lines ? "#AWS specific requirements
RUN apt update
RUN apt install -y curl
RUN npm install -g n"
If you can fix this..happy to accept pr
Yes
No
get this error do you have any idea
I fixed that one, but getting another one , have been searching for hours, but can't get it work. Do you have any idea?
oh man, that saved my life, should have asked you earlier lol. It's live now
Awesome
Will create a pull request to update the Dockerfile.prod and some fixes that I have done tonight
just wondering does it matter if I use different Redis for Strapi? Right now for Strapi, I use Redis from Railway. For Medusa, I used Redis from Azure
I made sure the MEDUSA_STRAPI_SCRET on Strapi match the JWT Secret on Medusa. But not sure why it is not connecting to Strapi. Below is the log from Medusa. Note: Medusa is on Azure and Strapi is on Railway.
2023-09-07T17:23:23.999331735Z: [INFO] {"level":"error","message":"response from the server: no-response,data: ","timestamp":"2023-09-07 17:23:23"}```
You need to set the strapi host to railway strapi host in medusa
Yes, I already set the STRAPI_SERVER_HOSTNAME to the Railway Strapi URL
Where is your medusa hosted?
Please check your security group or network firewall settings
Azure App Service
OK check the security group it should allow connections to port 1337
What is the port you have configured on medusa server
It should be 443
If you r connecting to railway
where can i check this
thisa is what i get from chat GPT "By default, Azure App Service only opens ports 80 and 443 for HTTP and HTTPS traffic respectively. If you need to expose a different port (like 1337), this is not directly achievable with Azure App Service."
I meany whi port have you used for strapi
Which*
In your strapi config
Sorry meant medusa config
I set env STRAPI_PORT=1337 on medusa
do i need to change the Expose in Dockerfile too? Or only change the STRAPI_PORT variable on Medusa to 443
Only strapi port on medusa
In the railway strapi settings add a port variable and set that to 1337
That will take care of mapping
that works
but on medusa I get "received request for page 1 from Strapi"
not sure why on strapi log I am getting
Have you created a user on strapi manually?
If you have delete that user
I think it's conflicting
I have not, I even created a new database for Strapi. Just change the user credetential on Medusa env to check if it fixed
Just wondering, if I delete a product on Strapi, will it be also deleted on Medusa?
No
Products need to be deleted on medusa to delete in strapi
Else strapi will recreate them
Just making sure if my backend is abc.com and admin is abc.com/app. It will be MEDUSA_BVAKEND_ADMIN=abc.com/app and MEDUSA_BACKEND_URL=abc.com
No
Medusa backend url will be https://abc.com
Watch the ABC Shows online at abc.com. Get exclusive videos and free episodes.
Backend admin will be https://abc.com/app
with the "/" at the end?
does the SAAS_REDIRECT_URL matter
is it not possible to achieve that ? delete on strapi and it will be delete on Medusa. Because on Medusa only allow to delete 1 by 1
Not at this point
As strapi is designed to run as slave to medusa
This implementation
I am not sure y medusa doesn't permit bulk deletes
You could add that on medusa github
So product ownership is with medusa
Not in your case
this is so weird. i just make a new database on railway and still got that error without creating any user yet
Please show your medusa log
The full medusa log
This could be a bug accidentally introduced
Can you share your full medusa log
yes
And complete strapi log
It looks like medusa isn't ready to respond at this time
But it resolves later on
Maybe autosync isn't working
You may need to trigger the sync manually on startup
how to do that, but i am able to add a product on medusa and it show up on strapi
and update content work
Yes..so they are talking
But the issue is auto sync
Auto sync is triggered at startup
That is when the plugin initialises
how to i do that
..manual sync startup is in the plugin readme
one thing I notice is when I delete a product on Medusa, all the product on Strapi disappear
Is that an error
i have added some extra fields to Product on Medusa backend, for example, isbn, I have added isbn field on Strapi admin, but it is not syncing that isbn field with Medusa. is there any extra step?
Hmm this needs a plugin fix
At the moment only default fields are allowed
You can write code and sync it
But the basic implementation doesn't do it
Will try to make a fix
Can you create issue in the repo for this
Or netter you van submit a pr
Is the sync the only issue
what file should I add that code
I will create an issue and look at the code in the weekend to see if i can fix it
UpdateStrapi.ts
i guess that is on the medusa-plugin-strapi-ts on Medusa. it is in node_modules. how do i change it
Have you worker with typescript before?
yes
like on medusa i yarn install medusa-plugin-strapi-ts . and I see the UpdateStrapi.ts file is installed in that one, which is located on node_modules. so i have to go to node_modules to change that file?
For testing you canbdo that
and how would i do that for production
i submit a pull request updating the dockerfile for prod and the updatestrapi to allow updating the custom fields to strapi
i have tested it and it worked
can you merge and release a nre version for medusa-plugin-strapi-ts. so it can work on my backend soon
Cool
Can uou add a test further dockerfile also
So that on future nothing breaks if changes are made
Also a test for the custom field
A very simple way to check integration is to start the medusa-strapi in test mode and run the medusa-plugin-strapi-ts tests
added.
i am not too sure about the docker, so i removed the previous PR and create new one just for medusa-plugin-strapi-ts to not only retrieve current specified fields but all the fields in clude custom fields.
just did it. can you check that PR. will check PR docker tomorrow night
Thanks
Can you please sign the PR
I have released a new version of the plugin..please test and let me know
you mean the medusa-plugin.strapi-ts? Yes it is syncing with custom fields now
i am going to look at the bugs that will hide the product when deleting a product on backend. would be easier for me, if you can point me at what files should I look at
There is only one file.. updatestrapi
And in strapi there is a utils folder.. in thar a utils file
not sure what is the problem. All of the products on Strapi disappear when deleting a product on Medusa or deleting a product on Strapi using the trash icon or when creating a product on Strapi and pressing Publish. I checked the database of Strapi, and all of the products are still in the database, not sure why it is not showing on Strapi after those actions
Where r u locates?
You can't create products on strapi
You can't delete products on strapi
The reason is that atrapi us designed to run as slave to medusa
When you create a product on strapi
It doesn't receive the medusa_id.. that is the product id field
That medusa generates
And you shouldn't do that
If you can send me a video of what is going on..I will be happy to fix it
When I delete a product on Medusa, all of the products on Strapi disappear
How many products do you have?
around 100 on production, and just 1x on development. but no matter of how many products that I have on both environments, all the products disappear on Strapi after a product is removed on Medusa
Hi there, nice thread to read and good collaboration here! Curious to know, is this already been solved?
I was unable to reproduce this
Ah ok, thanks for the quick reply! Will look into this somewhere this weekend and let you know if I'm encountering any issues or not.
Hi there, wondering if its possible to use your strapi-medusa component in my own mono repo and copy all the plugins to my medusa backend?
i've the following structure:
/medusa-monorepo
/backend
/storefront
/strapi
Hope you can guide me a bit...
It not clear for me how to use your repo tbh.
You;ve created a monorepo with 5 components. The components exists of medusa plugins but also a medusa app?
OK, you could add it as a submodule to your monorepo
If you want to preserve history
The strapi mono repo has a component call medusa-strapi. Which is an all encompassing strapi instance
The strapi repo is designed to run as a slave to medusa
Thanks for your response. And how do I handle the plugins? Do I need to manually copy paste them to the medusa-backend/plugins directory?
What about the strapi-plugin-multi-country-select then?
thats also a plugin that needs to be installed correct?
When I try to run yarn in the medusa-strapi directory i get an error:
warning Workspaces can only be enabled in private projects.
[5/5] 🔨 Building fresh packages...
[1/17] ⠁ better-sqlite3
[15/17] ⠁ strapi-plugin-generate-data
[10/17] ⠁ sharp
[7/17] ⠁ sharp
error /Users/user/Webprojects/client-monorepo/strapi/node_modules/better-sqlite3: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild --release
...
...
...
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/user/Webprojects/client-monorepo/strapi/node_modules/@lerna/add/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (node:events:527:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 22.5.0
gyp ERR! command "/Users/user/.nvm/versions/node/v16.15.0/bin/node" "/Users/user/Webprojects/client-monorepo/strapi/node_modules/.bin/node-gyp" "rebuild" "--release"
gyp ERR! cwd /Users/user/Webprojects/client-monorepo/strapi/node_modules/better-sqlite3
Im running node version v16.15.0 locally
Any clue how I can fix this?
No
All those are already installed in medusa-strapi
Ok im not able to locate them in the directory
Once yarn runs it installs them
But I think for now I have removed the country multi select due to a compatibility issue
I cant execute the command yarn in the repo getting the same error
now running the command yarn --ignore-engines
same error
to be clear, im running the command yarn --ignore-engines from the root of the repo
OK try one thing delete the yarn.lock
And node_modules
Are you running on windows?
I think it's similar to this https://github.com/nodejs/node-gyp/issues/2444
I encounter the following error, log says npm ERR! gyp info using [email protected] but if i use the command node-gyp -v v8.1.0 is displayed. How can i force npm to use the correct node-gyp version? n...
my python version is 3.11.4
Currently strapi is set to node 18
same error again
Coz I use the same everyday..so am not sure where the config difference is coming
Try the docker based version
You can issue s docker build inside medusa-strapi
Any luck?
Try use node v18.17.1
Sorry, all of sudden my kids were all around me... so later tonight when they are in bed I'll continue
😉
I tried it before with node v 18.17.0 without any luck and same goes for 18.17.1 version. It returned this error:
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=16.x.x". Got "18.17.1"
error Found incompatible module.
That's why I was using node version 16.x
Running yarn on node v16.15.0 returns the error:
error @strapi/[email protected]: The engine "node" is incompatible with this module. Expected version ">=18.0.0 <=20.x.x". Got "16.15.0"
error Found incompatible module.
Meaning that these two packages are not compatible with each other.
[email protected] needs node >=14.19.1 <=16.x.x
@strapi/[email protected] needs node >=18.0.0 <=20.x.x
I'll try to set it up from the scratch by ising the strapi documentation: yarn create strapi-app my-project --quickstart
I mean this documenation actuallly: https://docs.medusajs.com/plugins/cms/strapi
With node 18.7.1 use yarn --ignore engines
I need to fix the dependencies a little..thus all this confusion . Happy to accept a pr if you can fix it
Yeah I wanted to keep things simple and not too much other toolings like docker in order to make it work. I'll dig into your repo once I'll start configuring stuff and I gave you a star (for myself) 😉
... as in easy to find the repo again
:).. thanks.. if you can make it simpler.. happy to accept a PR.. this is sort of a batteries included repo. So there are quite a few dependencies
The problem is that many strapi plugins aren't Maintained.. so I end up forking them..fixing them and maintaining them in this repo
On my local system i configured strapi CMS running on localhost:1337 and also the medusa backend and frontend.
I have installed
medusa-plugin-strapi-ts in medusa and created strapi as per suggestion from medusa docs.
But i am getting below error on medusa backend log:
error: health check error connect ECONNREFUSED ::1:1337,data:```
Environment:
Mac M1
MacOs 14.0 (23A344)
Node 18.13.0