Closed elhananjair closed 1 year ago
It seems it works with other paths like /localhost
based on the way I am using the package and your demo here
Hi @elhananjair , The project you mentioned works just fine for me on firefox.
The errors you see are standard behaviour for some browsers due to page reloading (you're essentially closing the sse stream without notice when you close a tab).
I tested this on firefox version Mozilla Firefox 118.0.2
.
Your issue seems to be related http headers.
Your configuration is either missing some required headers for your setup or your disallowing some origins in your http response.
The event
itself allows you to set specific http headers, so you could do something like this
/** src/lib/server/longrunningtask.js */
import { event } from 'sveltekit-sse'
export function long_running_task() {
return event(async emit => {
//...
emit('some data...')
//...
})
.setHeader("Access-Control-Allow-Origin", "*")
.toResponse()
}
You probably shouldn't allow *
in a production environment though.
There's not much else I can help you with unless you reproduce the error in a repository where I can debug the project.
Yeah with .setHeader("Access-Control-Allow-Origin", "*")
it works fine.
Hello @tncrazvan After the update I am getting this error on firefox:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.