Skip to content

tossr & routify with host option set doesn't work #18

@KararTY

Description

@KararTY

I'm getting this beautiful error

0|Aquamon  | [tossr] url: /aquarium/kararty
0|Aquamon  | Error: TypeError: Invalid URL: ramsreef.com/aquarium/kararty
0|Aquamon  |     at errorHandler (/var/www/html/fishimon-server/node_modules/tossr/tossr.js:22:15)
0|Aquamon  |     at /var/www/html/fishimon-server/node_modules/tossr/tossr.js:107:25
0|Aquamon  |     at new Promise (<anonymous>)
0|Aquamon  |     at tossr (/var/www/html/fishimon-server/node_modules/tossr/tossr.js:79:12)
0|Aquamon  | [tossr] Error on url: /aquarium/kararty
0|Aquamon  | [tossr] Unhandled promise rejection:
0|Aquamon  | [tossr] Error: TypeError: Invalid URL: ramsreef.com/aquarium/kararty
0|Aquamon  |     at errorHandler (/var/www/html/fishimon-server/node_modules/tossr/tossr.js:22:15)
0|Aquamon  |     at /var/www/html/fishimon-server/node_modules/tossr/tossr.js:107:25
0|Aquamon  |     at new Promise (<anonymous>)
0|Aquamon  |     at tossr (/var/www/html/fishimon-server/node_modules/tossr/tossr.js:79:12)

Page it should request: src/pages/aquarium/[username].svelte

My server is setup like this

import Router from '@koa/router'
import { tossr } from 'tossr'

const TEMPLATE = 'public/index.html'
const SCRIPT = 'public/build/main.js' // dist/build/main.js if you're using dynamic imports
const OPTIONS = {
  inlineDynamicImports: true,
  host: process.env.HOSTNAME,
}
const route = new Router()

route.get('(.*)', async (ctx) => {
  const html = await tossr(TEMPLATE, SCRIPT, ctx.request.url, OPTIONS)

  ctx.body = html
})

export default route

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions