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

http://local.drupal8-host.dev:8000/node/2 401 (Unauthorized) #4

Open
iamstoick opened this issue Nov 19, 2014 · 3 comments
Open

http://local.drupal8-host.dev:8000/node/2 401 (Unauthorized) #4

iamstoick opened this issue Nov 19, 2014 · 3 comments

Comments

@iamstoick
Copy link

I am getting this error http://local.drupal8-host.dev:8000/node/2 401 (Unauthorized).Any idea what's is wrong with my setup? Basically I just followed the instructions on README.

I am not sure if I understand #3 Copy in the provided rest.settings.yml configuration. though.

@joshkoenig
Copy link
Owner

Couldn't tell you specifically, but it's a good opportunity to learn more about how HTTP routing and authorization works in D8! :)

@pxwise
Copy link

pxwise commented Dec 2, 2014

@geraldvillorente I ran into this same issue with my local D8 setup. It turned out to be a CORS issue.

Chrome console: XMLHttpRequest cannot load http://d8rest.local/node/1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3333' is therefore not allowed access.

I run nginx locally, so I was able to add one line in nginx.conf to bypass CORS. Be aware this is not a secure solution for a live web site but works fine for local development. For nginx, place this line somewhere in your nginx.conf server { } block:

add_header "Access-Control-Allow-Origin" $http_origin;

For Apache, see this article which includes a patch to .htaccess to bypass CORS restrictions.

@kamkejj
Copy link

kamkejj commented Feb 13, 2015

To answer the original question a little bit. After enabling the rest modules, enable permissions for the Anon user or authenticated user depending on what access you want for the GET, POST, PATCH, DELETE operations.

Using the Rest UI module adds a GUI to set the Rest configuration instead of using the rest.settings.yml file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants