Size: a a a

Next.js — русскоговорящее сообщество

2020 February 17

e

eeeMan in Next.js — русскоговорящее сообщество
if (pathname === '/service-worker.js') {
           res.setHeader('content-type', 'text/javascript');
           createReadStream('static/service-worker.js').pipe(res);
       } else {
           handle(req, res, parsedUrl);
       }
источник

T

Tolych in Next.js — русскоговорящее сообщество
У тебя только http подключён?
источник

T

Tolych in Next.js — русскоговорящее сообщество
Откуда берутся req, res ?
источник

e

eeeMan in Next.js — русскоговорящее сообщество
const {createServer} = require('http');
const {parse} = require('url');
const {createReadStream} = require('fs');
const ip = require('ip');
const next = require('next');

const dev = process.env.NODE_ENV !== 'production';
const app = next({dev});
const handle = app.getRequestHandler();

const port = process.env.PORT || 80;

app.prepare().then(() => {
   createServer((req, res) => {
       const parsedUrl = parse(req.url, true);
       const {pathname} = parsedUrl;

       if (pathname === '/service-worker.js') {
           res.setHeader('content-type', 'text/javascript');
           createReadStream('static/service-worker.js').pipe(res);
       } else {
           handle(req, res, parsedUrl);
       }
   }).listen(port, err => {
       if (err) throw err;
       console.log(`> Ready on http://${ip.address()}:${port}`)
   });
});
источник

T

Tolych in Next.js — русскоговорящее сообщество
eeeMan
const {createServer} = require('http');
const {parse} = require('url');
const {createReadStream} = require('fs');
const ip = require('ip');
const next = require('next');

const dev = process.env.NODE_ENV !== 'production';
const app = next({dev});
const handle = app.getRequestHandler();

const port = process.env.PORT || 80;

app.prepare().then(() => {
   createServer((req, res) => {
       const parsedUrl = parse(req.url, true);
       const {pathname} = parsedUrl;

       if (pathname === '/service-worker.js') {
           res.setHeader('content-type', 'text/javascript');
           createReadStream('static/service-worker.js').pipe(res);
       } else {
           handle(req, res, parsedUrl);
       }
   }).listen(port, err => {
       if (err) throw err;
       console.log(`> Ready on http://${ip.address()}:${port}`)
   });
});
Мне кажется nextjs не может использовать более одной папки для статики
источник

T

Tolych in Next.js — русскоговорящее сообщество
У него из коробки есть public, а далее все остальное средствами nginx
источник

e

eeeMan in Next.js — русскоговорящее сообщество
Tolych
У него из коробки есть public, а далее все остальное средствами nginx
ну это в последних версиях, раньше эта папка была не паблик, а статик
источник

T

Tolych in Next.js — русскоговорящее сообщество
Не вижу чтобы можно было бы использовать конструкции вида app.use(middleware)
источник

e

eeeMan in Next.js — русскоговорящее сообщество
хз, буду завтра разбираться
источник

T

Tolych in Next.js — русскоговорящее сообщество
eeeMan
ну это в последних версиях, раньше эта папка была не паблик, а статик
Ну или, использовать конструкцию, которая у тебя использовалась для сервис воркера. Из pathname разбирать наименование файла через regexp, и отдавать файлы в поток. При этом относительный путь к файлам определить через path.join() , path.resolve() на твой выбор
источник
2020 February 18

G

Github Releases Notify Bot in Next.js — русскоговорящее сообщество
zeit/next.js
v9.2.2-canary.22
источник

G

Github Releases Notify Bot in Next.js — русскоговорящее сообщество
zeit/next.js
Pre-release v9.2.2-canary.22
### Patches

- Simplify create-next-app README: #10545
- Speculate Navigations for Client-Side JS: #10560

### Credits

Huge thanks to @chibicode for helping!
источник

G

Github Releases Notify Bot in Next.js — русскоговорящее сообщество
zeit/next.js
Pre-release v9.2.2-canary.23
### Patches

- Remove ts-ignore where possible: #10541
- Remove react import in create-next-app template: #10564
- Add extra profiling app: #10568

### Credits

Huge thanks to @Janpot and @lfades for helping!
источник

G

Github Releases Notify Bot in Next.js — русскоговорящее сообщество
zeit/next.js
v9.2.2-canary.23
источник

G

Github Releases Notify Bot in Next.js — русскоговорящее сообщество
zeit/next.js
v9.2.2
### Patches

- Fix missing file extensions in docs: #10251
- De-dupe escape-regex with escape-string-regexp: #10257
- Update static check vars and fix types: #10260
- Update SSG types and clean up RenderOpts type: #10259
- Update _next/data URL handling in serverless-loader: #10261
- example with-typescript-graphql Fix type error: #10269
- Update built-in-css-support.md: c71694e28b11c9c3e909692c5614b2670cec01b2
- Update typo in typescript docs: #10276
- Update FaunaDB Example Instructions: #10280
- Add .jsx as a valid file extension in the pages directory: #10281
- Improved wording in comment: #10277
- Improve Stalled Requests Grammar: #10283
- Added support for BigInt to API routes: #10215
- Docs: remove --save from npm install; avoid system-ui: #10252
- Add catch all routes example and a link to it in docs: #10202
- Migrate CircleCi config to GitHub actions: #10274
- Fix Experimental Modern Mode with CSS: #10289
- Add initial support for unstable_getServerProps: #10077
- Fix with-orbit-components's name in package.json: #10307
- Fix typo in FaunaDB example: #10304
- Updated PostCSS docs and added a link to it: #10292
- Make sure to exit publish script with correct code: #10310
- Allowing skipping local selenium server when not needed: #10312
- Fix missing file extensions in docs: #10251
- De-dupe escape-regex with escape-string-regexp: #10257
- Update static check vars and fix types: #10260
- Update SSG types and clean up RenderOpts type: #10259
- Update _next/data URL handling in serverless-loader: #10261
- example with-typescript-graphql Fix type error: #10269
- Update built-in-css-support.md: c71694e28b11c9c3e909692c5614b2670cec01b2
- Update typo in typescript docs: #10276
- Update FaunaDB Example Instructions: #10280
- Add .jsx as a valid file extension in the pages directory: #10281
- Improved wording in comment: #10277
- Improve Stalled Requests Grammar: #10283
- Added support for BigInt to API routes: #10215
- Docs: remove --save from npm install; avoid system-ui: #10252
- Add catch all routes example and a link to it in docs: #10202
- Migrate CircleCi config to GitHub actions: #10274
- Fix Experimental Modern Mode with CSS: #10289
- Add initial support for unstable_getServerProps: #10077
- Fix preprocessor loader error: #10235
- Enable static 404 config to allow static 404 page when availab…: #10290
- Small grammar fix: #10317
- Fix: 9919 Add warning when no config is exported from next.con…: #10228
- Update workflow for testing against react@next: #10323
- Repair advanced feature reference: #10330
- Disable caching for react@next workflow as its not supported: #10331
- Experimental Nomodule polyfills chunk: #10212
- Update note about public and pages overlap: #10287
- Update the default template of create-next-app: #10327
- Upgrade with-carbon-components to built-in SCSS: #10321
- Fixes #10333 with-next-seo sample issues: #10335
- Fix api-routes-apollo-server-and-client-auth Example: #10334
- TypeScript documentation for _app.tsx: #10345
- Improve api-routes-apollo-server-and-client-auth Example: #10358
- Increase watch limit for GitHub actions testing: #10367
- Added fix for #8893: #10370
- Make sure to not override initial navigation when refreshing static page's query: #10353
- Add support for runtimeConfigs in serverless mode: #10365
- Add check that dynamic route is API route in handleApiRequest: #10360
- Implement experimental pages/404.js for custom 404 page: #10329
- Update Preact Example: #10380
- Custom AMP Validator Variable Name Collision Fix: #10371
- Fix bug in catch-all routes with SSG: #10379
- Update create app docs: #10382
- Make sure runtime config is set before any imports for serverless: #10386
- Update to not show API not ended warning when response is piped to: #10342
- Add TypeScript Definitions for Sass: #10363
- Remove Old Records: #10398
- Fix with-reasonml example: #10399
- New Jest Example: #10396
источник