Hot answers tagged

3

Just found the solution: npm install qs and import qs from 'qs' ... const actions = { auth({ commit }, { email, password }) { axios.post('url', qs.stringify({ your token data here })).then((res) => { console.log(res.data) }).catch((err) => { console.log(err) }) } }


2

They don't need to clash per se, but it depends on the way you build your project structure. I'm front-end focussed, so my setup is like: projectfolder src public public (you could also call this 'craft' or 'dist' or another name to indicate this is the final product) This is where Craft is installed with the craft installer. So nothing ...


1

with a get request from /index.php?p=admin/actions/users/session-info&dontExtendSession=1 I can get my CSRF Code + the User ID. Great.


1

And just like that I stumble over this wonderful blog post https://digitalevangelist.net/blog/vuejs-craft-cms-single-page-app-logging-in-to-craft


1

You would not use the headless API to submit content in into Craft, as neither the GraphQL or Element APIs support writing. The frontend entry form functionality is fairly well documented. You would just need your frontend to build out a post request including the correct action, CSRF token, and whatever fields are needed. The action endpoint will ...


1

The way Retour works, it doesn't do anything until Craft throws a 404 error. Some other plugins do this as well. Your route is such that anything Craft can't find goes to your SPA; that means Craft never throws a 404, so these tools will not do anything. What I'd suggest doing is have this redirect happen via your web server.


1

I ended up making a 404 template (which in atuality is the SPA index file) This causes the Craft redirects to take effect, and have the SPA as a fallback route. This means in Production i don't need any such route. For development purposes i do, so i made a conditional route file (to avoid the debug 404 of Craft): if(getenv('ENVIRONMENT') === 'dev') { ...


1

Not sure if it's a good call or not but you could have an endpoint that just has the {{ craft.app.request.csrfToken }} outputting on it. Poll(GET) that using ajax (axios or whatever you're using in your Vue app) and update your Vue model's csrf value with the response body? Same for the honeypot value I guess although I'm not that familiar with freeform I ...


1

You can use the asArray function to return arrays instead of elements {% set sections = craft .categories .group('teamCategory') .select(['title','elements.id','groupId']) .asArray() .all() %}


Only top voted, non community-wiki answers of a minimum length are eligible