Open mkgy opened 1 month ago
According to the details you provided, the web backend hasn't been running properly.
Requests to http://localhost:8000/api/auth/user
are responded 404
from nginx.
To run the entire project, make sure the backend is working properly.
The backend is running by laravel-nuxt3-api, which I'm running them in laravel/homestead, by the way, don't forget to change the default laravel nginx configs.
Hi DengSihan, thanks for the reply. I managed to setup up nginx. Now I am having problems with getting token from the backend. I receive the following error:
By nginx setting is as follows:
Hope you can help.
It seems like you are running laravel and nuxt on a Linux based localhost instead of a virtual machine like laravel/homestead.
your configs for /api
may look like below
try_files $uri $uri/ /index.php?$query_string;
here is my entire configs which is modified for your env
server {
listen 8000;
root "__your_laravel_project_dir__/public";
index index.html index.htm index.php;
charset utf-8;
proxy_set_header X-Forwarded-For $remote_addr;
location ~* ^/(api|broadcasting|storage|horizon|vendor|sitemap\.xml|robots\.txt) {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
proxy_pass http://127.0.0.1:3000;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
Hope it could help :) Feel free to ask if you have further questions
Hi DengSihan,
just tired your version. It also leads to the problem I mentioned previously. The Nginx server can hit the backend, because Laravel responds with details about my Browser. Here is a screenshot:
Howerver, it seems that (as menstioned previously) a token is never generated or passed on to my Browser. Here is a screenhot:
To my understanding right now, problem seems unrelated to whether the backend is being hosted in Linux environtment or in VM. Correct me if I am wrong.
By the way, where the Browser confirms errors:
Could you please show the response body of the POST:/api/auth/tokens
?
It works now. I don't know what I did :) I guess your version of nginx setup resulted in that. Here is the output now:
As you can see the token was received from Laravel backend by my client
Thank you very much for your patience and quick responce. I really appreciate that.
By the way i added the following setups:
Do you think they are neccessary ?
just configured github to authenticate a user. Unfortunately, when i enter the github credentials I get the following warning:
Any idea why this warning?
I have already generated client_id and client_secret credentials for github on my Github account and addes those credentials to .env file in laravel
this screenshot is from : /var/www/php_mvc/CodingChallenge/BEST/back_front_end/laravel-nuxt3-api/app/Http/Controllers/Auth/SocialTokensController.php
Hi DengSihan, regarding the redirect from backend to frontend after successful github authentication, I keep getting the following message :
How can I redisrect from domain http://localhost:8000 to http://localhost:3000 ? I have been spending a lot of time trying to make it work. Hope you can help with that.
Summary
Fail to register a new user
Steps to reproduce
configure nginx.conf to proxy to http://localhost:3000
reload nginx
configure nuxt.conf.js file as follows:
start the nuxt-project wth npm run dev
What is the current bug behavior?
Broswer error: POST http://localhost:8000/api/auth/user 404 (Page not found: /index.php)
What is the expected correct behavior?
Expecting to login
Relevant logs and/or screenshots