0
我有一個角應用(由角CLI內置),其經由express
託管在Heroku這種方式:如何將請求參數傳遞給Angular應用程序?
const express = require('express');
const app = express();
// Run the app by serving the static files
// in the dist directory
app.use(express.static(__dirname + '/dist'));
// Start the app by listening on the default
// Heroku port
app.listen(process.env.PORT || 8080);
這個程序是在vk.com
其中用戶的瀏覽器通過在請求中的字符串的iframe服務器,它承載我的應用程序,包含如用戶ID等。它看起來像這樣一些重要的信息(實際值替換爲星號):
path="/?api_url=https://api.vk.com/api.php&api_id=*&api_settings=1&viewer_id=*&viewer_type=4&sid=*&secret=*&access_token=*&user_id=0&group_id=*&is_app_user=1&auth_key=*&language=0&parent_language=0&is_secure=1&ads_app_id=*&referrer=unknown&lc_name=*&sign=*&hash="
有什麼辦法來提取這些值,並通過他們到應用程序之前,它轉到用戶的瀏覽器和加載?所以他們可以存儲在一個變量或類似的東西。
無法確定您的措詞是瀏覽器請求還是服務器響應。很難回答。模塊@ angular/http具有Request,Response,Headers,RequestOptions,URLSearchParams等內容。在Angular 2或4的上下文中在這些名稱上使用Google .. – JGFMK
當用戶使用帶有我的應用程序的iframe在'vk.com'打開頁面時,他的瀏覽器向我的託管應用程序發出了一個請求,這是一個javascript與'express'。在該腳本中,我可以獲得原始請求的所有參數,然後我需要將它們傳遞給通過'express'託管的實際Angular應用程序。 –