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

Error de CORS en Rutas api de Sveltekit #11494

Open
joeljosue49 opened this issue May 6, 2024 · 1 comment
Open

Error de CORS en Rutas api de Sveltekit #11494

joeljosue49 opened this issue May 6, 2024 · 1 comment
Labels
awaiting submitter needs a reproduction, or clarification

Comments

@joeljosue49
Copy link

Describe the bug

Tengo una app con rutas Api de Sveltekit y quiero usarlas desde otra App de Sveltekit
quisiera poder usarlas pero no me funcionan

:5001/login:1 Access to fetch at 'http://localhost:5000/api/conexion/' from origin 'http://localhost:5001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

tan simple como responder un TRUE desde la otra app....que deberia hacer?? help"! he intentado con hooks.server.js

export async function handle({ event, resolve }) {
if (event && event.request && event.request.url && event.request.url.pathname && event.request.url.pathname.startsWith('/api')) {

const customResponse = new Response('custom response', {
  'Access-Control-Allow-Origin': '*' 

    
});
return customResponse;

}

const response = await resolve(event);
return response;
}

Necesito ayuda...

Reproduction

export async function handle({ event, resolve }) {
if (event && event.request && event.request.url && event.request.url.pathname && event.request.url.pathname.startsWith('/api')) {

const customResponse = new Response('custom response', {
  'Access-Control-Allow-Origin': '*' 

    
});
return customResponse;

}

const response = await resolve(event);
return response;
}

Necesito ayuda...

Logs

No response

System Info

Sveltekit

Severity

annoyance

@Conduitry
Copy link
Member

Please write issues in English only. Please also don't use issues for support requests.

It sounds like the CORS preflight request is getting back a redirect, but you haven't provided enough information to see what that would be happening.

@Conduitry Conduitry added the awaiting submitter needs a reproduction, or clarification label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification
Projects
None yet
Development

No branches or pull requests

2 participants