Skip to content

Commit

Permalink
fix: server url property (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Dec 23, 2021
1 parent 2b571ad commit a9b2004
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "0.0.16-0",
"version": "0.0.16-1",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"scripts": {
"build": "node scripts --tsc --build --api --platform-binding --wasm",
Expand Down
2 changes: 1 addition & 1 deletion src/server/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface DocumentOptions {
// (undocumented)
debug?: boolean;
// (undocumented)
url?: string;
url?: URL;
}

// @alpha
Expand Down
2 changes: 1 addition & 1 deletion src/server/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function createGlobal(opts?: GlobalOptions): QwikGlobal {
opts = opts || {};

const doc: QwikDocument = domino.createDocument() as any;
const baseURI = typeof opts.url !== 'string' ? BASE_URI : opts.url;
const baseURI = opts.url === undefined ? BASE_URI : opts.url.href;
const loc = new URL(baseURI, BASE_URI);

Object.defineProperty(doc, 'baseURI', {
Expand Down
2 changes: 1 addition & 1 deletion src/server/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function createPlatform(document: any, opts?: DocumentOptions) {
const doc: Document = document;

if (opts?.url) {
doc.location.href = new URL(opts.url, 'http://qwik.local').href;
doc.location.href = opts.url.href;
}
const symbolCache = new Map<string, { [symbol: string]: any }>();
const serverPlatform: CorePlatform = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface QwikDocument extends Document {}
* @public
*/
export interface DocumentOptions {
url?: string;
url?: URL;
debug?: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion src/testing/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface DocumentOptions {
// (undocumented)
debug?: boolean;
// (undocumented)
url?: string;
url?: URL;
}

// @alpha
Expand Down
2 changes: 1 addition & 1 deletion src/testing/document.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { pathToFileURL } from 'url';
describe('global', () => {
it('should create document', () => {
const global = createGlobal({
url: pathToFileURL(__filename).href,
url: pathToFileURL(__filename),
});
expect(global.document.baseURI).toContain('file://');
expect(global.document.baseURI).toContain('document.unit.ts');
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "npm run clean && concurrently -c blue,green \"rollup -c --configDev --watch\" \"wait-on public/build && npm run serve\""
},
"devDependencies": {
"@builder.io/qwik": "~0.0.15",
"@builder.io/qwik": "0.0.16-1",
"@rollup/plugin-node-resolve": "^13.0.6",
"concurrently": "^6.4.0",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-builder/src/index.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function renderApp(opts: RenderToStringOptions) {
<head>
<title>Qwik Blank App</title>
</head>
<body>
<body q:base="/build/">
<Header />
<div id="my-content"></div>
<Footer />
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-partytown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"serve": "echo \"server not setup\""
},
"devDependencies": {
"@builder.io/qwik": "~0.0.15",
"@builder.io/qwik": "0.0.16-1",
"@rollup/plugin-node-resolve": "^13.0.6",
"concurrently": "^6.4.0",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-partytown/src/index.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function renderApp(opts: RenderToStringOptions) {
<title>Qwik + Partytown Blank App</title>
<script defer async src="~partytown/debug/partytown.js"></script>
</head>
<body>
<body q:base="/build/">
<MyApp />
<script type="text/partytown">
({partyTownExampleWhichBlocksMainThreadForOneSecond.toString()})()
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"serve": "node server/index.js"
},
"devDependencies": {
"@builder.io/qwik": "~0.0.15",
"@builder.io/qwik": "0.0.16-1",
"@rollup/plugin-node-resolve": "^13.0.6",
"concurrently": "^6.4.0",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter/src/index.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function renderApp(opts: RenderToStringOptions) {
<head>
<title>Qwik Blank App</title>
</head>
<body>
<body q:base="/build/">
<MyApp />
<QwikLoader debug={opts.debug} />
</body>
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "npm run clean && concurrently -c blue,green \"rollup -c --configDev --watch\" \"wait-on public/build && npm run serve\""
},
"devDependencies": {
"@builder.io/qwik": "~0.0.14",
"@builder.io/qwik": "0.0.16-1",
"@rollup/plugin-node-resolve": "^13.0.6",
"concurrently": "^6.4.0",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion starters/servers/cloudflare/src/index.cloudflare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function handleQwik(event: any, request: Request) {
}

const ssrResult = await renderApp({
url: request.url,
url: new URL(request.url),
symbols,
});

Expand Down
4 changes: 1 addition & 3 deletions starters/servers/express/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ async function startServer() {
async function handleQwik(req, res) {
const result = await renderApp({
symbols,
url: req.url,
url: new URL(req.url),
debug: true,
});
res.send(result.html);
}

const app = express();
const publicDir = join(__dirname, '..', 'public');
const buildDir = join(__dirname, '..', 'public', 'build');
app.use(express.static(publicDir));
app.use(express.static(buildDir));

// Optionally server Partytown if found.
const partytownDir = join(__dirname, '..', 'node_modules', '@builder.io', 'partytown', 'lib');
Expand Down

0 comments on commit a9b2004

Please sign in to comment.