Point subscribe call to correct endpoint
This commit is contained in:
parent
784eccb92a
commit
2e777d3376
|
|
@ -0,0 +1,5 @@
|
|||
import type { Response, Request } from "express"
|
||||
|
||||
export function subscribe(req: Request, res: Response) {
|
||||
res.status(200).send()
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ function LandingMessage({ isSupported }: { isSupported: boolean }) {
|
|||
function EnableButton({ onSubscribe }: { onSubscribe: () => void }) {
|
||||
const { subscribeToPush, requestPermission, canSendPush } = usePush()
|
||||
|
||||
async function subscribe() {
|
||||
function subscribe() {
|
||||
console.log("Hey the thing was clicked wow")
|
||||
requestPermission()
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ function EnableButton({ onSubscribe }: { onSubscribe: () => void }) {
|
|||
subscribeToPush(
|
||||
urlB64ToUint8Array(applicationServerPublicKey) as any,
|
||||
(subscription) => {
|
||||
fetch("/subscribe", {
|
||||
fetch("/api/subscribe", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(subscription),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ describe("when user is on iOS", () => {
|
|||
permission: "default",
|
||||
requestPermissionResult: "granted",
|
||||
})
|
||||
await page.route("/subscribe", async (route) => {
|
||||
await page.route("/api/subscribe", async (route) => {
|
||||
await route.fulfill()
|
||||
})
|
||||
})
|
||||
|
|
@ -62,7 +62,7 @@ describe("when user is on iOS", () => {
|
|||
}) => {
|
||||
await page.goto("/")
|
||||
|
||||
const requestPromise = page.waitForRequest("/subscribe")
|
||||
const requestPromise = page.waitForRequest("/api/subscribe")
|
||||
await page.getByText(/Enable notifications/).click()
|
||||
const request = await requestPromise
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ describe("when user is on iOS", () => {
|
|||
}) => {
|
||||
await page.goto("/")
|
||||
|
||||
const requestPromise = page.waitForRequest("/subscribe")
|
||||
const requestPromise = page.waitForRequest("/api/subscribe")
|
||||
await page.getByText(/Enable notifications/).click()
|
||||
await requestPromise
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ import express from "express"
|
|||
|
||||
// notice that the result of `remix vite:build` is "just a module"
|
||||
import * as build from "./build/server/index.js"
|
||||
import { subscribe } from "./api/subscribe.js"
|
||||
|
||||
const app = express()
|
||||
app.use(express.static("build/client"))
|
||||
app.get("/api", (req, res) => res.send("HI"))
|
||||
app.post("/api/subscribe", subscribe)
|
||||
|
||||
// and your app is "just a request handler"
|
||||
app.all("*", createRequestHandler({ build }))
|
||||
|
|
|
|||
Loading…
Reference in New Issue