Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use client dev-server proxy lsp request #1754

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Composer/packages/client/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ module.exports = {
appSrc: resolveApp('src'),
appTsConfig: resolveApp('tsconfig.json'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
proxySetup: resolveApp('src/setupProxy.js'),
testsSetup: resolveModule(resolveApp, 'setupTests'),
proxySetup: resolveModule(resolveApp, 'setupProxy'),
appNodeModules: resolveApp('../../node_modules'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
Expand Down
14 changes: 14 additions & 0 deletions Composer/packages/client/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const proxy = require('http-proxy-middleware');

const paths = require('./config/paths');
const proxySetting = require(paths.appPackageJson).proxy;

module.exports = function(app) {
const wsProxy = proxy('/lg-language-server', {
target: proxySetting.replace('/^http/', 'ws'),
changeOrigin: true,
ws: true,
});

app.use(wsProxy);
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ interface CodeEditorProps {
line: number;
}

// lsp server port should be same with composer/server port.
const lspServerPort = process.env.NODE_ENV === 'production' ? process.env.PORT || 3000 : 5000;
const lspServerPath = '/lg-language-server';

export default function CodeEditor(props: CodeEditorProps) {
Expand Down Expand Up @@ -137,7 +135,6 @@ export default function CodeEditor(props: CodeEditorProps) {
errorMsg={errorMsg}
lgOption={lgOption}
languageServer={{
port: Number(lspServerPort),
path: lspServerPath,
}}
onChange={_onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import debounce from 'lodash/debounce';

import { FormContext } from '../types';

const lspServerPort = process.env.NODE_ENV === 'production' ? process.env.PORT || 3000 : 5000;
const lspServerPath = '/lg-language-server';

const LG_HELP =
Expand Down Expand Up @@ -120,7 +119,6 @@ export const LgEditorWidget: React.FC<LgEditorWidgetProps> = props => {
hidePlaceholder={true}
helpURL={LG_HELP}
languageServer={{
port: Number(lspServerPort),
path: lspServerPath,
}}
height={height}
Expand Down