Please note that KirbyText is just an extension of Markdown, which is an extension of HTML. Which means: KirbyText may as well contain HTML. Therefore you need to strip all HTML tags from the KirbyText on the client side or you might as well parse KirbyText on the backend. However stripping HTML may not mitigate all attacks (like XSS in a link tag).
My recommendation is to only load resources from trusted sources anyway, then you won‘t need all that complex and potentially still not 100 % secure client logic.
Access to XML:HttpRequest at 'http://localhost:888/api/pages/test'
from origin 'http://localhost:8080' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the
requested resource.
If I connect with Postman, it works fine, though.
Does anyone have the same issue? Or any idea on how to fix that?
And before that I even get a 404 on the api page… Even though it is definitely there…
I’m a big fan of the new API feature but with Kirby 2 I built I own api routes through the templates and that worked much easier somehow.
As an example for your case, you might configure the proxy from /kirby to http://localhost:888/api/. That way your server will pass the apis to the kirby backend transparently and you won’t have cors issues.
Hey, I just discovered the amazing REST API Kirby 3 comes with and in the last few days I’ve been trying to create a simple, straightforward, zero-setup port of the Starterkit to Vue.js.
imho the panel access is required since the API was designed to work very closely with the panel. almost all returned data is structured for what the panel needs.
if you are looking for a simple but secure way to query the api consider using @rbnschlz plugin: https://github.com/robinscholz/better-rest
i comes with a user blueprint just like you posted built right in.
i keep getting authorization problems with the better-rest plugin.
i created a new api user and set the user blueprint coming with the plugin. i set the 'basicAuth' => true in the config.php file.
i’m running locally with valet and enabled https for the website. i also tried to set 'allowInsecure' => true in the config.php to overcome the possible https-not-working problem.
still no luck when visiting <local.dev>/rest/site. am i missing something?
Hello! Since some people starred the last project I made I guess they found it useful, therefore I made some additional improvements in it. And I even made a fork from it which uses a slightly different approach but makes more sense, requires 0 configuration and is more elegant.
It uses Kirby 3 as headless CMS, Vue.js for frontend, same as before, but instead of fetching the data with the REST API I just turned all the templates to .json representations and consume them from the vue frontend.
@jmedveckyh Thanks a lot for sharing your solution .
Could you please add a license note regarding Kirby to your Readme? Otherwise people who come across your repo might think that Kirby is free software.