my svelte code is:
<script lang="ts">
import { onMount } from "svelte";
let qdata = Object;
let url = "";
onMount(() => {
url = "http://127.0.0.1:8000/apisearch/".concat(window.location.href.substr(31));
fetch(url)
.then(res => res.json())
.then(dat => console.log(dat));
}); //get query
let h = "http://127.0.0.1:8000/apisearch/".concat(url);
</script>
{url}
<div class="grid justify-center rounded bg-slate-500">
{#each qdata as result}
<p>{result}</p>
{/each}
</div>
The error I get is Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8000/apisearch/test. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.
My backend is built in rust with the rocket framework. I am using sveltekit.