I have a fronted vue3 web application.
I am currently experiencing the following problems.
But i don’t know why happened and how fix it..
I think the error is due to looking for a static file called callback, but I thought it would be handled correctly by vue-router because it routes to index.html if the file is not found.
If anyone can tell me why, I’d be glad to know.
□Error
2024/07/23 09:37:09 [error] 29#29: *9 open() "/usr/share/nginx/html/callback" failed (2: No such file or directory), client: 10.1.1.70, server: localhost, request: "GET /callback?code=22c784ca-4973-4268-96d4-735dba9ddf08 HTTP/1.1", host: "mask.mask.com", referrer: "https://mask.auth.mask.amazoncognito.com/"
□Context
My app is SPA Web application that has Authentication function with Amazon Cognito.
Then I am making the redirection process is called after the login is completed.
The login process is completed work but after redirect to my app, Following error is shown on browser.
enter image description here
I had checked nginx error log and the log said the above error message
□Vue router
import { createRouter, createWebHistory } from 'vue-router'
import MedicalPlanDocView from '../views/MedicalPlanDocView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'medicalPlanDocView',
component: MedicalPlanDocView
},
{
path: '/callback',
name: 'callback',
redirect: to => {
const code = to.query.code as string
sessionStorage.setItem("code",code)
return "/"
}
}
]
})
export default router
□Nginx
server {
server_name front;
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
I have tried to modify nginx like following but did work.
□Nginx
server {
server_name front;
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location /callback {
try_files $uri $uri/ /;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
daigo tsuchiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.