#medusa-plugin-strapi sync data medusa-strapi

274 messages · Page 1 of 1 (latest)

tired tide
#

I try to use medusa-plugin-strapi and in order to sync date from medusa to strapi I run http://localhost:9000/hooks/seed and got:
400 error: "Webhook error: Custom repository Repository was not found. Did you forgot to put @EntityRepository decorator on it?"

half crater
hasty cove
half crater
#

Can you share your medusa log?

hasty cove
half crater
#

And the strapi log plz

hasty cove
hasty cove
half crater
#

Have you configured all the jwt keys and secrets

hasty cove
# half crater 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.

half crater
#

Yes perfect

#

Can you try pulling the master branch again

#

We pushed a couple of fixes today

hasty cove
hasty cove
half crater
#

Plz share the logs

hasty cove
half crater
#

Have you configured medusabackend url in strPi?

#

You need install.medusa-plugin-strapi-TS

hasty cove
#

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

half crater
#

Don't create user

#

Medusa will create it

#

This created a conflict

hasty cove
#

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

half crater
#

You can host it wherever

#

There is docker file

half crater
hasty cove
half crater
#

Only medusa strapi folder

hasty cove
# half crater 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

half crater
#

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

hasty cove
#

Do I have to change anything in the Docker

half crater
#

Only setup environment variables

hasty cove
half crater
#

Your welcome

hasty cove
half crater
#

No

hasty cove
# half crater No

just in the env file? so dont have to do anything in Dockerfile? I see there is one dockerfile and dockerfile.prod

half crater
#

It needs to be supplied to thr docker runtime

#

Use dockerfile for dev

hasty cove
# half crater Use dockerfile for dev

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

half crater
#

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

hasty cove
#

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

half crater
#

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

hasty cove
#

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"

half crater
#

If you can fix this..happy to accept pr

hasty cove
#

it should also be removed right

half crater
#

No

hasty cove
hasty cove
# half crater No

I fixed that one, but getting another one , have been searching for hours, but can't get it work. Do you have any idea?

half crater
#

Set the host value to 0.0.0.0

#

In strapi environment variables

hasty cove
#

Awesome

#

Will create a pull request to update the Dockerfile.prod and some fixes that I have done tonight

hasty cove
hasty cove
# half crater Set the host value to 0.0.0.0

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"}```
half crater
#

You need to set the strapi host to railway strapi host in medusa

hasty cove
half crater
#

Where is your medusa hosted?

#

Please check your security group or network firewall settings

hasty cove
half crater
#

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

hasty cove
#

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."

half crater
#

I meany whi port have you used for strapi

#

Which*

#

In your strapi config

#

Sorry meant medusa config

hasty cove
#

I set env STRAPI_PORT=1337 on medusa

half crater
#

Set that to 443

#

As railwa connects over https

hasty cove
half crater
#

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

hasty cove
#

but on medusa I get "received request for page 1 from Strapi"

#

not sure why on strapi log I am getting

half crater
#

Have you created a user on strapi manually?

#

If you have delete that user

#

I think it's conflicting

hasty cove
#

Just wondering, if I delete a product on Strapi, will it be also deleted on Medusa?

half crater
#

Products need to be deleted on medusa to delete in strapi

#

Else strapi will recreate them

hasty cove
half crater
#

No

hasty cove
half crater
#

No

#

Sorry that / isn't required

#

Rather shouldn't be used

hasty cove
hasty cove
half crater
#

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

half crater
hasty cove
half crater
#

Please show your medusa log

#

The full medusa log

#

This could be a bug accidentally introduced

#

Can you share your full medusa log

hasty cove
half crater
#

And complete strapi log

half crater
#

But it resolves later on

#

Maybe autosync isn't working

#

You may need to trigger the sync manually on startup

hasty cove
#

and update content work

half crater
#

Yes..so they are talking

#

But the issue is auto sync

#

Auto sync is triggered at startup

#

That is when the plugin initialises

hasty cove
half crater
#

..manual sync startup is in the plugin readme

hasty cove
#

Is that an error

hasty cove
half crater
#

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

hasty cove
hasty cove
half crater
hasty cove
half crater
#

Have you worker with typescript before?

hasty cove
half crater
#

It's in the repo

#

Then you install it

#

Then it will setup in node modules

hasty cove
# half crater Then it will setup in node modules

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?

half crater
#

For testing you canbdo that

hasty cove
half crater
#

Once you are successful.. submit a pr

#

And I will release a new version

hasty cove
#

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

half crater
#

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

hasty cove
hasty cove
# half crater Cool

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.

half crater
#

Can you rebsse to development branch

#

Can you create a new pr for docker

hasty cove
half crater
#

Thanks

half crater
#

Can you please sign the PR

half crater
#

I have released a new version of the plugin..please test and let me know

hasty cove
half crater
#

Cool

#

Thanks

hasty cove
# half crater Cool

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

half crater
#

There is only one file.. updatestrapi

#

And in strapi there is a utils folder.. in thar a utils file

hasty cove
# half crater 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

half crater
#

Where r u locates?

half crater
#

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

hasty cove
half crater
#

How many products do you have?

hasty cove
# half crater 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

jovial glen
half crater
#

I was unable to reproduce this

jovial glen
#

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.

jovial glen
#

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?

half crater
#

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

jovial glen
#

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?

half crater
#

No

#

Just yarn add medusa-plugin-strapi-ts

jovial glen
#

What about the strapi-plugin-multi-country-select then?

#

thats also a plugin that needs to be installed correct?

jovial glen
#

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?

half crater
#

Run yarn in the repo

#

And use yarn --ignore-engines

half crater
#

All those are already installed in medusa-strapi

jovial glen
#

Ok im not able to locate them in the directory

half crater
#

Once yarn runs it installs them

#

But I think for now I have removed the country multi select due to a compatibility issue

jovial glen
#

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

half crater
#

OK try one thing delete the yarn.lock

#

And node_modules

#

Are you running on windows?

jovial glen
#

nope Mac

#

M1 chip

#

13.4.1

#

Os

#

Running right now,, tbc

half crater
jovial glen
#

my python version is 3.11.4

half crater
#

Currently strapi is set to node 18

jovial glen
#

same error again

half crater
#

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

half crater
echo dune
#

Try use node v18.17.1

jovial glen
# half crater Any luck?

Sorry, all of sudden my kids were all around me... so later tonight when they are in bed I'll continue

#

😉

jovial glen
#

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

half crater
#

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

jovial glen
#

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

half crater
#

:).. 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

undone pier
#

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
half crater
#

Your server isn't up

#

Are you using ipv6