mirror of
https://github.com/fmhy/edit.git
synced 2026-02-19 01:31:41 +11:00
fix cors
This commit is contained in:
parent
3a71e8f164
commit
7213a1f4af
5 changed files with 26 additions and 5 deletions
6
.vitepress/middleware/cors.ts
Normal file
6
.vitepress/middleware/cors.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { corsEventHandler } from "nitro-cors";
|
||||
|
||||
export default corsEventHandler((_event) => { }, {
|
||||
origin: "*",
|
||||
methods: "*",
|
||||
});
|
||||
|
|
@ -47,5 +47,5 @@ export default defineEventHandler(async (event) => {
|
|||
throw new Error(error);
|
||||
});
|
||||
|
||||
return "success";
|
||||
return { status: "success" };
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,12 +42,11 @@ async function handleSubmit(type?: string) {
|
|||
contactEmail: feedback.contactEmail,
|
||||
};
|
||||
|
||||
// TODO: fix this horror?
|
||||
try {
|
||||
const response = await fetch("https://feedback.tasky.workers.dev", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "POST",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
|
|
@ -59,7 +58,9 @@ async function handleSubmit(type?: string) {
|
|||
error.value = data.error;
|
||||
return;
|
||||
}
|
||||
success.value = true;
|
||||
if (data.status === "success") {
|
||||
success.value = true;
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
} finally {
|
||||
|
|
@ -103,7 +104,10 @@ async function handleSubmit(type?: string) {
|
|||
<textarea v-model="feedback.message" autofocus class="input" />
|
||||
<p class="desc">Contacts, so we can get back to you. (Optional)</p>
|
||||
<textarea v-model="feedback.contactEmail" class="contact-input" />
|
||||
<button class="btn btn-primary" :disabled="!feedback.message" @click="handleSubmit()">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
:disabled="feedback.message.length > 10"
|
||||
@click="handleSubmit()">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue