Hello,
I deployed my custom embedded app in cloudflare successfully. Now I want to store sessionObject in mysql db of my own. But if I do it, cloudflare is throwing an error. App is not displaying.
let _sessionStorage: MySQLSessionStorage | null = null;
function getSessionStorage() {
if (!_sessionStorage) {
\_sessionStorage = new MySQLSessionStorage(
"mysql://user:user%40123@153.178.2.241:3306/user"
);
Hey @Hema_Varshini_B - I agree with Dylan on this one. If you’re able to share the exact error message, that would be super helpful! I also wanted to share this documentation that might help with your set up if you haven’t taken a look at it yet (looks like you’re setting up a CF worker directly?):
If the above doesn’t help, please feel free to ping me here with that specific error message and I can take a look
More of a Cloudflare question than a Shopify question I think but, after resolving this issue, you may still have trouble running the Mysql Session Storage package on Cloudflare. It’s designed for a stateful server with a connection pool, with Cloudflare (or any serverless worker) you’re going to be reinitializing a new connection pool on every single request.
If you’re open to modifying the Mysql session package, you could use Cloudflare Hyperdrive - I would only suggest this if you’re working on an existing app with real store sessions in your Mysql.
If this is a new app, Cloudflare KV is an excellent option for your session storage since you’re already hosting on Cloudflare, and you can use Shopify’s dedicated package out of the box.