saleor / apps

A central space for Saleor Apps, integrations, and the App Store 🚀
https://apps.saleor.io
Other
107 stars 299 forks source link

Unable to configure Upstash APL in Saleor apps (CMS,Slack) #363

Closed wackyesolution closed 1 year ago

wackyesolution commented 1 year ago

I am facing an issue while configuring Upstash APL in Saleor apps. Specifically, in the application "saleor-app-checkout" (present in the frontend), I have successfully configured Upstash using the following variables: APL=upstash, UPSTASH_REDIS_REST_URL= URL, and UPSTASH_REDIS_REST_TOKEN= TOKEN.

However, in the Saleor apps like "saleor-app-cms" and "saleor-app-slack," I am only able to use APL=file, but I want to use Upstash.

Steps to reproduce the issue:

  1. Create a free account on Upstash and create a free Redis DB.
  2. In the Docker stack of various apps, insert the following env variables:
APL=upstash
UPSTASH_URL=<UPSTASH_REDIS_REST_URL>
UPSTASH_TOKEN=<UPSTASH_REDIS_REST_TOKEN>
SECRET_KEY = KEY
DEBUG=app-sdk:*
TZ=Europe/Rome
ENABLE_SSL=True
  1. With everything deployed, load the app manifest from the link https://link_app/api/manifest from the dashboard.

Result:

When I try to load the manifest, it fails to write the APL on Upstash and fails with an error from the frontend: "Registration failed: could not save auth data," while in the app's terminal, with active debugging, I receive this error:

saleor-app-slack@1.4.0 start /app/apps/slack
next start
ready - started server on 0.0.0.0:1819, url: http://localhost:1819/
2023-04-08T11:44:39.687Z app-sdk:Middleware:withBaseURL Middleware called with host: slackapp.app.com, protocol https
2023-04-08T11:44:39.687Z app-sdk:Middleware:withBaseURL context.baseURL resolved to be: "DOMIONIO DEL APP CENSURATO"
2023-04-08T11:44:40.072Z app-sdk:Middleware:withSaleorDomainPresent Middleware called with domain in header: api.censured.com
2023-04-08T11:44:40.072Z app-sdk:Middleware:withAuthTokenRequired Middleware called
2023-04-08T11:44:40.073Z app-sdk:createAppRegisterHandler Request received
2023-04-08T11:44:40.578Z app-sdk:APL:UpstashAPL saveDataToUpstash() called with: {"saleorApiUrl":"[https://api.censured.com/graphql/","token":"vEgd"}](https://api.censured.com/graphql/%22,%22token%22:%22vEgd%22%7D)
2023-04-08T11:44:40.579Z app-sdk:APL:UpstashAPL Sending request to Upstash
2023-04-08T11:44:40.730Z app-sdk:APL:UpstashAPL Operation unsuccessful. Upstash API has responded with 400 code
2023-04-08T11:44:40.730Z app-sdk:APL:UpstashAPL Error message: ERR failed to parse command
2023-04-08T11:44:40.731Z app-sdk:createAppRegisterHandler There was an error during saving the auth data

Note:

wackyesolution commented 1 year ago

Hello guys, anyone has a resolution for my issue? Do you have some problem such like mine using upstash APL or not?

lkostrowski commented 1 year ago

Hey @wackyesolution , we will look into that.

lkostrowski commented 1 year ago

Rel https://github.com/saleor/saleor-app-sdk/issues/198

wackyesolution commented 1 year ago

I will try to fix it manually meanwhile I'm glad I wasn't making a mistake in the configurations. Do you have in mind a fix in the future for the next releases?

lkostrowski commented 1 year ago

@krzysztofwolski is looking in to that at the moment, we will release a fix this week

The problem is caused by JWKS that is saved in Upstash, we will probably encode it to base64

krzysztofwolski commented 1 year ago

The fix has been added in the latest release: https://github.com/saleor/saleor-app-sdk/releases/tag/v0.37.3 @wackyesolution Thanks again for reporting the issue