Skip to content
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

CORS issue with Kirby QL #53

Closed
sophiamsb opened this issue Oct 24, 2023 · 10 comments
Closed

CORS issue with Kirby QL #53

sophiamsb opened this issue Oct 24, 2023 · 10 comments
Labels
needs: information ❓ Requires more information to proceed

Comments

@sophiamsb
Copy link

Description

After Updating Kirby 3.9.7 to Kirby 4.0.0-beta-2 , the request query status responds with error code 401 with message "Unauthenticated".

Expected behavior
The request should be successful and return status code 200 OK

Screenshots
Here is my config.php and .htaccess files to document accessibility. It works fine with Kirby 3.9.7

Screenshot 2023-10-24 at 11 44 52 Screenshot 2023-10-24 at 11 45 26

To reproduce

  1. Replace Kirby folder on the server
  2. Go to browser and reach the website url
  3. Go to dev tools and check console message
    Result : Error message
    " POST https://my-website.com/api/query 403 (forbidden) "

Your setup

Kirby Version
Update from Kirby 3.9.7 to Kirby 4.0.0-beta-2

Your system (please complete the following information)

  • Device: Mac Pro
  • OS: macOS Monterey
  • Browser: Chrome/ Safari / Firefox

Additional context
using Kirby QL and React

@lukasbestle lukasbestle transferred this issue from getkirby/kirby Oct 24, 2023
@lukasbestle
Copy link
Member

lukasbestle commented Oct 24, 2023

I'm confused. Is it "HTTP 401 Unauthenticated" or "HTTP 403 Forbidden"? Also, have you checked if your custom route to respond to OPTIONS requests still works?

(In the future, please post your code in Markdown code blocks like:

```php
$your->code();
```

so we can more easily reproduce the issue without having to manually type the text from the screenshots.)

@sophiamsb
Copy link
Author

sophiamsb commented Oct 24, 2023 via email

@lukasbestle
Copy link
Member

Looks like GitHub didn't know what to do with your attached screenshots. Could you please post them via the GitHub UI?

@lukasbestle lukasbestle added the needs: information ❓ Requires more information to proceed label Oct 24, 2023
@sophiamsb
Copy link
Author

Sure !

Here are the screenshots:
Screenshot 2023-10-24 at 13 28 23
Screenshot 2023-10-24 at 13 28 13

About the custom route responding to OPTIONS requests , where can I check that ?

@lukasbestle
Copy link
Member

The HTTP 403 response can have many reasons. Could you please post the full response including the response body?

Regarding the OPTIONS request: You can test that with the following from the browser console:

await fetch("https://dev.sophiamsaoubi.net/api/query", {method: "OPTIONS"});

Alternatively you can use tools like cURL on the command line or (if you prefer GUI tools) there are also HTTP apps to test the request.

@sophiamsb
Copy link
Author

Here is the full response body:
Screenshot 2023-10-25 at 13 39 42

and when I check the OPTIONS request I get this:
Screenshot 2023-10-25 at 13 41 32

But when I do the OPTIONS request with the url of on my current website which works, I get the same output...

@lukasbestle
Copy link
Member

From your screenshot it's a bit hard to see what's going on with the OPTIONS request.

But unrelated to that, the issue you are having with KQL (from the first screenshot) is that the current stable version does not yet support Kirby 4. Could you please try if the changes from this PR fix the issue for you? #52

@sophiamsb
Copy link
Author

I tried some stuff but still not working... is it the correct fix ?

path: site/plugins/kql/composer.json
change this

"require": {
		"php": ">=8.0.0 <8.3.0",
		"getkirby/cms": ">=3.8.2",
		"getkirby/composer-installer": "^1.2.1"
	},

to this

"require": {
		"php": ">=8.0.0 <8.3.0",
		"getkirby/cms":"^3.9",
		"getkirby/kql": "dev-v4-compat",
		"getkirby/composer-installer": "^1.2.1"
	},

path: site/plugins/kql/src/Kql/interceptors/cms/Content.php
change this

<?php

namespace Kirby\Kql\Interceptors\Cms;

use Kirby\Kql\Interceptor;

class Content extends Interceptor
{

to this

<?php

namespace Kirby\Kql\Interceptors\Cms;

use Kirby\Kql\Interceptors\Content\Content as NewContent;

class Content extends NewContent
{

@lukasbestle
Copy link
Member

We've released KQL 2.1.0 today, which officially supports Kirby 4. Could you please try updating to that and check if it works for you?

@sophiamsb
Copy link
Author

I upgraded the KQL and it's working ! Thanks for the support :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: information ❓ Requires more information to proceed
Projects
None yet
Development

No branches or pull requests

3 participants