-
Notifications
You must be signed in to change notification settings - Fork 84
feat(#146): allow loading license from server config #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Is there a permissions issue for /ckeditor/config? I'm still on Strapi 4, but receiving a 401 unauthorized error. |
|
Per Claude (but works on my machine): Fix CKEditor License Key Authentication IssueProblemThe Root CauseThe CKEditor plugin was using the deprecated SolutionUpdated the license API to use the modern Key Changes:
Files Modified
- import { request } from "@strapi/helper-plugin";
-
- const licenseRequests = {
- getLicense: async () => await request(`/ckeditor/config`, { method: "GET" }),
- };
-
- export default licenseRequests;
+ const licenseRequests = {
+ getLicense: async (fetchClient) => {
+ const response = await fetchClient.get("/ckeditor/config");
+ return response;
+ },
+ };
+
+ export default licenseRequests;
src/plugins/strapi-plugin-ckeditor/admin/src/components/CKEditorProvider/index.js
import { memo, useEffect, useState } from "react";
import { useCKEditorCloud } from "@ckeditor/ckeditor5-react";
- import licenseRequests from "../../api/license";
+ import { useFetchClient } from "@strapi/helper-plugin";
+ import licenseRequests from "../../api/license";
const { options } = attribute;
+ const fetchClient = useFetchClient();
const [licenseKey, setLicenseKey] = useState(options?.licenseKey);
useEffect(() => {
- licenseRequests.getLicense().then((response) => {
+ licenseRequests.getLicense(fetchClient).then((response) => {
const licenseKeyFromServer = response.data?.ckeditor?.licenseKey;
if (licenseKeyFromServer) {
setLicenseKey(licenseKeyFromServer);
}
- });
- }, []);
+ }).catch((error) => {
+ console.error("Failed to fetch CKEditor license key:", error);
+ });
+ }, [fetchClient]);
Technical Details
The useFetchClient hook automatically:
* Adds JWT authentication headers via request interceptors
* Handles 401 responses with automatic logout
* Uses the supported Strapi v4 API patterns
Benefits
* ✅ Resolves authentication errors for CKEditor license endpoint
* ✅ Maintains clean code architecture with proper abstraction
* ✅ Uses modern, supported Strapi APIs instead of deprecated functions
* ✅ Improves error handling and debugging capabilities
* ✅ Follows React hooks best practices
Testing
* License key should now load successfully for authenticated admin users
* "Loading License Key..." message should disappear after successful API call
* CKEditor should initialize with proper license configuration |
This PR is for Strapi v5, and tested it worked very well. |
|
using v5.23 i experience 401 as well on fetching keys |
Allow loading license from server config, so that:
schema.jsonFor verifying it, I've published a fork
@jeff-tian/strapi-plugin-ckeditor, which works as expected.Server Config
Add a
CKEDITOR_LICENSE_KEYto the environment variable to allow the client side to load: