-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow web users to access auth:api guarded routes. #806
Conversation
It looks like this problem goes back to this commit at the end of January. Looks to be related to removing |
I'm not aware of any problems with this currently and haven't heard such from any other users. @themsaid: is it possible Beau is missing something in his templates? A meta tag? Can you try to recreate this issue? |
Using a simple route:
I was able to do this:
All seems to be working fine, how can I replicate? Also what errors are you getting? |
@simensen axios automatically puts a |
@themsaid you did this in Spark behind the API guard? |
@taylorotwell yes using the |
I think I've located the source of the problem. I'll update this as soon as I have confirmation on a fix. |
The problem seems to be coming from the fact that I'm using tightenco/ziggy. This issue looks to explain my problem: tighten/ziggy#64 After diving into Axios I found the part that automatically adds the X-XSRF-TOKEN header and added some debugging code. The problem came from This was my calling code: var store_uri = this.owner.type === 'user'
? route('api.user.projects.store')
: route('api.team.projects.store', {team_slug: this.owner.slug});
var form = this.form;
var owner = this.owner;
axios.post(store_uri, form)... I added an explicit
Thanks for helping me figure this out. It was quite a pain in the ass since all signs seemed to indicate it should "just work." Someday I'd like to not run into freaky edge cases. :) |
I've been running into an issue with getting access to my API routes using my logged in user session via Axios. After a lot of debugging, it looked like I was only sending the
X-CSRF-TOKEN
header. My browser was not sendingX-XSRF-TOKEN
.I was able to verify that my
XSRF-TOKEN
cookie was set, so I couldn't figure out what was wrong withinterceptors.js
.Turns out
interceptors.js
is no longer being used?I moved the related logic to
spark-bootstrap.js
near where theX-CSRF-TOKEN
is added now. I'm now able to make Axios requests to my api routes without a problem.If there is a better way for me to do this, let me know. I'm happy to update this patch as required.